Anda di halaman 1dari 17

#include<graphics.

h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#include<stdio.h>
FILE *fin,*fout;
struct gas_reg
{
char add[30];
int age;
long tel;
long regno;
char name[20];
}gas;

int regdeleterecord(long reg)


{
char choice;
int x;
fin=fopen("gas_reg","rb");
if(fin==NULL)
return 0;
fout=fopen("tempgas","wb");
rewind(fin);
x=0;
while(fread(&gas,sizeof(gas),1,fin)!=NULL)
{
if(gas.regno!=reg)
fwrite(&gas,sizeof(gas),1,fout);
else
{
clrscr();

printf("\n***************************************************************")
;
regdisp();
printf("\n***************************************************************")
;
printf("\nAre You Sure To Delete(Y/N)\t");
fflush(stdin);
scanf("%d",&choice);
if(choice!='y'&&choice!='Y')
fwrite(&gas,sizeof(gas),1,fout);
else
{
x=1;
}//close of else
}//close of else
}//close of while
fclose(fin);
fclose(fout);
remove("gas_reg");
rename("tempgas","gas_reg");
if(x==0)
return 1;
else
return 2;

}
int regmodify(long reg)
{
char choice;
int x;
fin=fopen("gas_reg","rb");
if(fin==NULL)
return 0;
fout=fopen("tempgas","wb");

rewind(fin);
x=0;
while(fread(&gas,sizeof(gas),1,fin)!=NULL)
{
if(gas.regno!=reg)
fwrite(&gas,sizeof(gas),1,fout);
else
{
clrscr();
printf("\n***************************************************************")
;
regdisp();
printf("\n***************************************************************")
;
printf("\nAre You Sure To Modify(Y/N)\t");
fflush(stdin);
scanf("%d",&choice);
if(choice!='y'&&choice!='Y')
fwrite(&gas,sizeof(gas),1,fout);
else
{
regread();
x=1;
fwrite(&gas,sizeof(gas),1,fout);
}//close of else
}//close of else
}//close of while
fclose(fin);
fclose(fout);
remove("gas_reg");
rename("tempgas","gas_reg");
if(x==0)
return 1;
else
return 2;

}//close of modify function


void registration()
{
int x,max;
fin=fopen("gas_reg","rb");
if(fin==NULL)
{
gas.regno=1958;
}//close of if
else
{
rewind(fin);
x=0;
while(fread(&gas,sizeof(gas),1,fin)!=NULL)
{
if(x==0)
max=gas.regno;
if(max<gas.regno)
max=gas.regno;
x++;
}//close of while loop
fclose(fin);
gas.regno=max+1;
}//close of else
}//close of registration
int regsearch(long reg)
{
fin=fopen("gas_reg","rb");

if(fin==NULL)
return 0;
rewind(fin);
printf("\n***************************************************************")
;
while(fread(&gas,sizeof(gas),1,fin)!=NULL)
{
if(gas.regno==reg)
regdisp();
}
printf("\n***************************************************************")
;
fclose(fin);
return 1;
}//close of search

regread()
{
printf("\nYour Registration No. is\t %d ",gas.regno);
printf("\nEnter the Name\t");
fflush(stdin);
gets(gas.name);
printf("\nEnter the Age\t");
fflush(stdin);
scanf("%d",&gas.age);
printf("\nEnter the Telephone\t");
fflush(stdin);
scanf("%d",&gas.tel);
printf("\nEnter the Address\t");
fflush(stdin);
gets(gas.add);
}
//close of function

//writing data on to file


void regwritetofile()
{
fout=fopen("gas_reg","ab");
fwrite(&gas,sizeof(gas),1,fout);
fclose(fout);
}
//reading data from file
regdisp()
{
printf("\nREG No: %d ",gas.regno);
printf("Name:\t%s",gas.name);
printf("\t\t\tAge:\t%d",gas.age);
printf("\nAddress:\t%s",gas.add);
printf("\tTel:\t%ld",gas.tel);
}
int regreadfromfile()
{
fin=fopen("gas_reg","rb");
if(fin==NULL)
return 0;
rewind(fin);
printf("\n***************************************************************")
;
while(fread(&gas,sizeof(gas),1,fin)!=NULL)
regdisp();
printf("\n***************************************************************")
;
fclose(fin);
return 1;
}//close of reading from file

// ---Closing of class GAS REGISTRATION --// --- start of menu for GAS REGISTRATION ---

int registration_menu()
{
int ch;
int result;
long regno;
menu:
clrscr();
printf("\n\t\t****************************************************");
printf("\n\t\t\t\tGas Registration Menu");
printf("\n\t\t****************************************************");
printf("\n\t\t\t1.Registration\n\t\t\t2.View All\n\t\t\t3.View by REG NO.\n\t\t\t4.Modify
Details\n\t\t\t5.Delete Record\n\t\t\t6.Previous Menu");
printf("\n\t\t****************************************************");
printf("\n\t\t\tEnter Your Choice\t");
fflush(stdin);
scanf("%d",&ch);
switch(ch)
{
case 1:
registration();
regread();
regwritetofile();
printf("\nThanks");
getch();
goto menu;
case 2:
clrscr();
result=regreadfromfile();
if(result==0)
printf("\nNo Records");
getch();
goto menu;

case 3:
printf("\nEnter the Registration No\t");
scanf("%d",&regno);
clrscr();
result =regsearch(regno);
if(result==0)
printf("\nNo Such Record");
getch();
goto menu;
case 4:
printf("\nEnter the REG No\t");
scanf("%d",&regno);
result=regmodify(regno);
if(result==0)
printf("\nRecord Not Founded");
else if(result==1)
printf("\nRecord Not Modified");
else
printf("\nThanks for Modification");
getch();
goto menu;
case 5:
printf("\nEnter the REG No\t");
scanf("%d",&regno);
result=regdeleterecord(regno);
if(result==0)
printf("\nRecord Not Founded");
else if(result==1)
printf("\nRecord Not Deleted");
else
printf("\nThanks for Deletion");
getch();
goto menu;

case 6:
return 0;
}
}
// ---CLOSE OF GAS REGISTRATION MENU AND ITS CLASS
// ---START OF BOOKING OF GAS
struct booking
{
char name[20];
long regno;
struct date bookingdate;
struct date deliverydate;
char status;
}book;
int regdelivery()
{
long reg;
int found;
char choice;
struct booking t;
printf("\nEnter the Registration No\t");
scanf("%d",&reg);
fin=fopen("booking","rb");
if(fin==NULL)
return 0;
rewind(fin);
found=0;
fout=fopen("tempbooking","wb");
while(fread(&book,sizeof(book),1,fin)!=NULL)
{
if(book.regno!=reg)
fwrite(&book,sizeof(book),1,fout);

else
{
bookdisp();
printf("\nAre you sure to For this Delivery(Y/N)\t");
fflush(stdin);
scanf("%c",&choice);
if(choice!='y'&&choice!='Y')
fwrite(&book,sizeof(book),1,fout);
else
{
book.status='y';
fwrite(&book,sizeof(book),1,fout);
}//close of else
}//close of else
}//close of while loop
fclose(fin);
fclose(fout);
remove("booking");
rename("tempbooking","booking");
return 1;
}//close of delivery
int checkbooking(long reg)
{
struct date tempdate;
struct booking temp;
fin=fopen("booking","rb");
if (fin==NULL)
return 1;
rewind(fin);
getdate(&tempdate);
while(fread(&temp,sizeof(temp),1,fin)!=NULL)
{

if(reg==temp.regno && tempdate.da_mon==temp.bookingdate.da_mon &&


tempdate.da_year==temp.bookingdate.da_year)
{
printf("\nBooking Date:%d",(int)temp.bookingdate.da_day);
printf("-%d",(int)temp.bookingdate.da_mon);
printf("-%d",(int)temp.bookingdate.da_year);
fclose(fin);
return 2;
}
fclose(fin);
return 1;
}//close of while loop
}//close of checkbooking function

int bookread()
{
int found,result;
struct gas_reg g;
struct booking t;
printf("\nEnter the Reg No:\t");
scanf("%d",&book.regno);
fin=fopen("gas_reg","rb");
if(fin==NULL)
return 0;
rewind(fin);
found=0;
while(fread(&g,sizeof(g),1,fin)!=NULL)
{
if(g.regno==book.regno)
{
found=1;
strcpy(book.name,g.name);
}
}//close of while loop

fclose(fin);
if (found==0)
return 0;
result=checkbooking(book.regno);
if(result==2)
return 2;
getdate(&book.bookingdate);
printf("\nBooking Date");
printf("\t%d",(int)book.bookingdate.da_day);
printf("-%d",(int)book.bookingdate.da_mon);
printf("-%d",(int)book.bookingdate.da_year);
book.status='n';
return 1;
}//close of read for booking
void bookwritetofile()
{
fout=fopen("booking","ab");
fwrite(&book,sizeof(book),1,fout);
fclose(fout);
}//close of write function
bookdisp()
{
printf("\nReg No:\t%d",book.regno);
printf("\tName:\t\t%s",book.name);
printf("\t\tBooking Date:%d-%d-%d",(int)book.bookingdate.da_day,
(int)book.bookingdate.da_mon,(int)book.bookingdate.da_year);
printf("\n-------------------------------------------------------------------");
}//close of display function
int bookreadfromfile()
{
fin=fopen("booking","rb");

if(fin==NULL)
return 0;
rewind(fin);
clrscr();
printf("\n***************************************************************")
;
while(fread(&book,sizeof(book),1,fin)!=NULL)
{
if(book.status=='n')
bookdisp();
}//close of while loop
printf("\n***************************************************************")
;
fclose(fin);
return 1;
}//close of reading from file
int bookingmenu()
{
struct booking bk;
int choice,result;
bookmenu:
clrscr();
printf("\n\t\t**************************************************");
printf("\n\t\t\tBOOKING MENU");
printf("\n\t\t**************************************************");
printf("\n\t\t1.Booking of Gas\n\t\t2.View Bookings\n\t\t3.Delivery of Gas\n\t\t4.Previous
Menu");
printf("\n\t\t**************************************************");
printf("\n\t\tEnter your choice\t");
fflush(stdin);
scanf("%d",&choice);
switch(choice)
{
case 1:
result=bookread();

if (result==0)
printf("\nNo Such Registration");
else if (result==2)
printf("\nBooking Already been done...");
else
bookwritetofile();
getch();
goto bookmenu;
case 2:
result=bookreadfromfile();
if(result==0)
printf("\nNo Records");
getch();
goto bookmenu;
case 3:
result=regdelivery();
if(result==0)
printf("\nNo Such Booking");
else
printf("\nThanks for Delivery");
getch();
goto bookmenu;
case 4:
return 0;
}
}
void firstscreen();
//close of booking class and its main menu
void main()
{
int choice;

firstscreen();
mainmenu:
clrscr();
printf("\n\t\t**************************************************");
printf("\n\t\t\tMAIN MENU");
printf("\n\t\t**************************************************");
printf("\n\t\t\t1.Registration\n\t\t\t2.Booking Menu\n\t\t\t3.About Company
\n\t\t\t4.Help\n\t\t\t5.Exit");
printf("\n\t\t**************************************************");
printf("\n\t\t\tEnter Your choice\t");
scanf("%d",&choice);
switch(choice)
{
case 1:
registration_menu();
goto mainmenu;
case 2:
bookingmenu();
goto mainmenu;
case 3:
{
getch();
clrscr();
printf("\n Sun Gas Agancy is the Leading Gas Agancy in Karnal\n");
printf("\n Sun Gas is the Agancy of india Oil Company \n");
printf("\n Our Company Starts From 2000 \n");
printf("\n We have 2000 Clender Capacity \n");
printf("\n We have Total no of Emp 20 \n");
printf("\n We have a Manager and A Supervisor \n");
getch();
goto mainmenu;
}
case 4:
{

getch();
clrscr();
printf("\n

SUN GAS AGANCY \n");

printf("\n\n\t\t MANAGER
printf("\n\n\t\t SUPERVISOR

ANIL KUMAR => 9856478951");


PARVEEN

=> 8547587985");

printf("\n\n\t\t GAS AGANCY 0184-2457854");


getch();
goto mainmenu;
}
case 5:
exit(0);
}
}

/*GRAPHICS FUNCTION */
void firstscreen()
{
int gm=DETECT;
initgraph(&gm,&gm,"");
setcolor(BLUE);
setfillstyle(SOLID_FILL,RED);
//for(int i=0;i<=1000;i++)
//putpixel(random(639),random(479),random(15)+1);
//ellipse(300,150,0,360,20,10);
//line(280,150,280,200);
//line(320,150,320,200);
//fillellipse(300,200,40,20);
//fillellipse(300,300,40,20);
//line(260,200,260,300);
//line(340,200,340,300);
//floodfill(300,230,BLUE);
setcolor(YELLOW);

circle(50,50,50);
circle(30,30,5);
circle(70,30,5);
ellipse(50,70,180,0,10,5);
//circle(550,50,50);
//circle(530,30,5);
//circle(570,30,5);
//ellipse(550,70,180,0,10,5);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
setcolor(YELLOW);
sound(1345);
outtextxy(140,30,"SUN GAS BOOKING & REGISTRATION");
sleep(3);
outtextxy(200,330,"INDANE Gas");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(200,240,"

S U N");

outtextxy(200,270,"

G A S ");

outtextxy(200,290,"A G A N C Y S");
setcolor(RED);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
outtextxy(160,450,"Developed By - PRIYANKA");
nosound();
getch();
closegraph();
}

Anda mungkin juga menyukai