Tuesday, 24 February 2015

GAS AGENCY PROJECT IN C


#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <dos.h>

struct booking
   {
      long int consno;
      char consname[50];
      char cylntype;
      long int noofcyln;
      char bookingdate[30];
   };
struct price
   {
      char cylntype;
      float price;
   };
struct custmast
   {
      long int consno;
      char consname[50];
      char consadd1[150];
      long int pincode;
      long int telephone;
      char dateofcon[30];
      long int noofcyln;
      char cylntype;
   };
struct stock
   {
      char arrivaldate[30];
      char consname[50];
      long int ccommercial;
      long int cdomestic;
      long int scommercial;
      long int sdomestic;
      long int ncommercial;
      long int ndomestic;
   };
struct transaction
   {
      long int consno;
      char consname[50];
      char dateofcon[150];
      char address[150];
      long int pincode;
      long int telephone;
      long int sino;
      long int noofcyln;
      char cylntype;
      char bookingdate[30];
      char releaseddate[30];
      char remark[200];
   };


void Introduction();
void MainMenu();
void CustomerEntry();
void StockEntry();
void Transaction();
void Report();
void Booking();
void Price();
void CEAddition();
void CEModification();
void CEDeletion();
void CEView();
void BAddition();
void BView();
void BModification();
void BDeletion();
void StockEntry();
void CustomerReport();
void DailyTransactionReport();
void WeeklyTransactionReport();
void Price();
void PWork();
void PView();
void Transaction();
void printline();
void Hashline();
void Percentline();
void Addline();

void main()
{
    highvideo();
    Introduction();
    MainMenu();
    getch();
}


void Introduction()
{
   clrscr();
   printf("\n\n\n\t\t\t ANUSHA GAS AGENCY ");
   printf("\n\n\t\t\t  CHEYYAR-604407             \n");
   Percentline();
   printf("\n\t\t\t WELCOME ");
   printf("\n\n\t\t\t\t TO ");
   printf("\n\n\n\t\t\t\t\tOUR AGENCY \n");
   Percentline();
   printf("\n\n\n\t\t\t Press A Key To Continue ");
   getch();
   return;
}

void MainMenu()
{
    int ch,i=0;
    MENU:
    clrscr();
    printline();
    printf("\t\t\t\t MAIN MENU SCREEN ");
    printline();
    printf("\n\n\n");
    printf("\n\t\t\t 1.Customer Entry.   ");
    printf("\n\t\t\t 2.Stock Entry.      ");
    printf("\n\t\t\t 3.Transaction.      ");
    printf("\n\t\t\t 4.Booking.          ");
    printf("\n\t\t\t 5.Price.            ");
    printf("\n\t\t\t 6.Report.           ");
    printf("\n\t\t\t 7.Exit.             ");
    CHOICE:
printf("\n\n\n\n\n\tEnter your choice        : ");
scanf("%d",&ch);
if(ch<1 || ch>7)
  goto CHOICE;

    switch(ch)
      {
case 1:
   CustomerEntry();
   break;
case 2:
   StockEntry();
   break;
case 3:
   Transaction();
   break;
case 4:
   Booking();
   break;
case 5:
   Price();
   break;
case 6:
   Report();
   break;
case 7:
   exit(0);
       }
      goto MENU;
}


void CustomerEntry()
{
    int ch,i;
    MENU:
    clrscr();
    printline();
    printf("\t\t\t\t CUSTOMER ENTRY SCREEN ");
    printline();
    printf("\n\n\n\t\t\t 1.Addition.");
    printf("\n\t\t\t 2.Modification.");
    printf("\n\t\t\t 3.Deletion.");
    printf("\n\t\t\t 4.View.");
    printf("\n\t\t\t 5.Previous Menu.");
    CHOICE:
       printf("\n\n\n\n\n\t Enter your Choice    : ");
       scanf("%d",&ch);
       if(ch<1 || ch>5)
  goto CHOICE;
     switch(ch)
      {
case 1:
  CEAddition();
  break;
case 2:
  CEModification();
  break;
case 3:
  CEDeletion();
  break;
case 4:
  CEView();
  break;
case 5:
  MainMenu();
      }
     goto MENU;
}


void Booking()
{
   int ch,i;
   MENU:
   clrscr();
   printline();
   printf("\t\t\t\t BOOKING SCREEN ");
   printline();
   printf("\n\n\n\t\t\t    1.Addition .");
   printf("\n\t\t\t    2.Modification.");
   printf("\n\t\t\t    3.Deletion.");
   printf("\n\t\t\t    4.View.");
   printf("\n\t\t\t    5.Previous Menu .");
   CHOICE:
      printf("\n\n\n\n\n\t Enter your choice    : ");
      scanf("%d",&ch);
      if(ch<1 || ch>5)
      goto CHOICE;

    switch(ch)
     {
case 1:
 BAddition();
 break;
case 2:
 BModification();
 break;
case 3:
 BDeletion();
 break;
case 4:
 BView();
 break;
case 5:
 MainMenu();
    }
    goto MENU;
}

void StockEntry()
{
    struct stock s;
    FILE *yu;
    yu=fopen("STOCK.DAT","r");
    if((fread(&s,sizeof(s),1,yu))==NULL)
      {
strcpy(s.consname,"");
strcpy(s.arrivaldate,"");
s.ccommercial=0;
s.cdomestic=0;
s.scommercial=0;
s.sdomestic=0;
s.ncommercial=0;
s.ndomestic=0;
fclose(yu);
yu=fopen("STOCK.DAT","w");
fwrite(&s,sizeof(s),1,yu);
fclose(yu);
      }
    clrscr();
    printline();
    printf("\t\t\t\t STOCK ENTRY SCREEN ");
    printline();
    printf("\n\n\n");
    printf("\t\t Enter the Customer Name  : ");
    fflush(stdin);
    gets(s.consname);
    printf("\n\t\t Enter the Arrival Date   : ");
    gets(s.arrivaldate);
    yu=fopen("STOCK.DAT","r");
    fread(&s,sizeof(s),1,yu);
    clrscr();
    printf("\n\n\n\n");
    printline();
    printf("\t\t\t\t CURRENT STOCK ");
    printline();
    printf("\n\t\t\t Current Commercial : %ld",s.ccommercial);
    printf("\n\n\t\t\t Current Domestic   : %ld",s.cdomestic);
    printf("\n");
    printline();
    getch();
    clrscr();
    Addline();
    printf("\t\t\t\t\t\t STOCK RECEIVED ");
    Addline();
    printf("\n\t\t\t Commercial : ");
    scanf("%ld",&s.scommercial);
    printf("\n\t\t\t Domestic   : ");
    scanf("%ld",&s.sdomestic);
    printf("\n");
    Addline();
    printf("\t\t\t\t\t NO OF DEFECTIVE STOCKS ");
    Addline();
    printf("\n\t\t\t In Commercial : ");
    scanf("%ld",&s.ncommercial);
    printf("\n\t\t\t In Domestic   : ");
    scanf("%ld",&s.ndomestic);
    Addline();
    s.ccommercial+=s.scommercial-s.ncommercial;
    s.cdomestic+=s.sdomestic-s.ndomestic;
    fclose(yu);
    yu=fopen("STOCK.DAT","w");
    fwrite(&s,sizeof(s),1,yu);
    fclose(yu);
    getch();
    fclose(yu);
    return;
}

void Price()
{
    int ch,i;
    MENU:
    clrscr();
    printline();
    printf("\t\t\t\t PRICE SCREEN");
    printline();
    printf("\n\n\n");
    printf("\n\t\t\t 1.Pwork. ");
    printf("\n\t\t\t 2.pview. ");
    printf("\n\t\t\t 3.Previous Menu.");
    CHOICE:
       printf("\n\n\n\n\n\t Enter your choice    :");
       scanf("%d",&ch);
       if(ch<1  ||  ch>3)
 goto CHOICE;
    switch(ch)
     {
case 1:
  PWork();
  break;
case 2:
  PView();
  break;
case 3:
  MainMenu();
     }
   goto MENU;
}

void Transaction()
{
    struct booking b;
    struct custmast c;
    struct stock s;
    struct transaction t;
    long int no;
    char consname1[150];
    char arrivaldate1[30];
    long int ccommercial1;
    long int cdomestic1;
    long int scommercial1;
    long int sdomestic1;
    long int ncommercial1;
    long int ndomestic1;
    FILE *B,*C,*S,*T;
    B=fopen("BOOK.DAT","rb+");
    C=fopen("GAS.DAT","rb+");
    S=fopen("STOCK.DAT","r");
    T=fopen("TRAN.DAT","ab+");
    clrscr();
    printline();
    printf("\t\t\t\t TRANSACTION SCREEN ");
    printline();
    printf("\n\n\n\t Enter a Customer Number For Transaction :");
    scanf("%ld",&no);
    while((fread(&c,sizeof(c),1,C))  !=  NULL)
      {
if(c.consno==no)
{
  t.consno=c.consno;
  strcpy(t.consname,c.consname);
  strcpy(t.address,c.consadd1);
  t.pincode=c.pincode;
  strcpy(t.dateofcon,c.dateofcon);
  t.telephone=c.telephone;
  t.noofcyln=c.noofcyln;
  t.cylntype=c.cylntype;
}
     }
    while((fread(&b,sizeof(b),1,B)) != NULL)
      {
if(b.consno==no)
{
  strcpy(t.bookingdate,b.bookingdate);
}
      }
 printf("\n\t Customer Number            : %ld",t.consno);
 printf("\n\t Customer Name              : %s",t.consname);
 printf("\n\t Customer Address           : %s",t.address);
 printf("\n\t Pincode                    : %ld",t.pincode);
 printf("\n\t Telephone Number           : %ld",t.telephone);
 printf("\n\t Date Of Connection         : %s",t.dateofcon);
 printf("\n\t Number of the Cylinder     : %ld",t.noofcyln);
 printf("\n\t Cylinder Type              : %c",t.cylntype);
 printf("\n\t Date of Booking            : %s",t.bookingdate);
 getch();
 clrscr();
 printf("\n\n\n");
 printf("\n\t Enter the serial Number    :");
 scanf("%ld",&t.sino);
 printf("\n\t Enter the Date of Release  :");
 fflush(stdin);
 gets(t.releaseddate);
 printf("\n\t Remarks    :");
 fflush(stdin);
 gets(t.remark);
 fwrite(&t,sizeof(t),1,T);
 S=fopen("SE.DAT","r");
 fread(&s,sizeof(s),1,S);
      strcpy(arrivaldate1,s.arrivaldate);
      strcpy(consname1,s.consname);
      ccommercial1=s.ccommercial;
      cdomestic1=s.cdomestic;
      scommercial1=s.scommercial;
      sdomestic1=s.sdomestic;
      ncommercial1=s.ncommercial;
      ndomestic1=s.ndomestic;
      if (toupper(t.cylntype)=='D')
{
  cdomestic1=s.cdomestic-1;
}
      else
{
  ccommercial1=s.ccommercial-1;
}
 fclose(S);
 S =fopen("SE.DAT","w");
     strcpy(s.arrivaldate,arrivaldate1);
     strcpy(s.consname,consname1);
     s.ccommercial=ccommercial1;
     s.cdomestic=cdomestic1;
     s.scommercial=scommercial1;
     s.sdomestic=sdomestic1;
     s.ncommercial=ncommercial1;
     s.ndomestic=ndomestic1;
     fwrite(&s,sizeof(s),1,S);
      fclose(T);
      fclose(B);
      fclose(C);
      fclose(S);
   return;
}

void Report()
{
   int ch,i;
   MENU:
   clrscr();
   printline();
   printf("\t\t\t\t   REPORT SCREEN     ");
   printline();
   printf("\n\n\n");
   printf("\t\t 1.Customer Report.  ");
   printf("\n\t\t 2.Daily Transation Report.");
   printf("\n\t\t 3.Weekly Report.");
   printf("\n\t\t 4.Previous Menu.");
   CHOICE:
      printf("\n\n\n\n\n\t Enter your Choice : ");
      scanf("%d",&ch);
      if(!(ch>0 && ch<5))
 goto CHOICE;
   switch(ch)
     {
case 1:
  CustomerReport();
  break;
case 2:
  DailyTransactionReport();
  break;
case 3:
  WeeklyTransactionReport();
  break;
case 4:
  MainMenu();
     }
   goto MENU;
}


void CEAddition()
{
    struct custmast r;
    FILE *eb;
    char flag;
    eb=fopen("GAS.DAT","ab+");
    clrscr();
    do
     {
printline();
printf("\t\t\t ADDITION SCREEN    ");
printline();
printf("\n\n\n Enter the following asked details ");
printf("\n\n\n\n\t  Customer Number        : ");
scanf("%ld",&r.consno);
printf("\n\t  Customer  Name         : ");
fflush(stdin);
gets(r.consname);
printf("\n\t  Customer's Address     : ");
gets(r.consadd1);
fflush(stdin);
printf("\n\t  Pin Code               : ");
scanf("%ld",&r.pincode);
printf("\n\t  Telephone Number       : ");
fflush(stdin);
scanf("%ld",&r.telephone);
printf("\n\t  Date Of Connection     : ");
fflush(stdin);
gets(r.dateofcon);
clrscr();
printf("\n\n\n");
printf("\n\t  Number of the Cylinder : ");
scanf("%ld",&r.noofcyln);
printf("\n\t  Cylinder Type          : ");
fflush(stdin);
scanf("%c",&r.cylntype);
fwrite(&r,sizeof(r),1,eb);
fflush(stdin);
puts("\n\n Add one more Records [Y/N]   : ");
flag=getchar();
clrscr();
     }while(toupper(flag)=='Y');
     fclose(eb);
   return;
}


void CEModification()
{
   struct custmast r;
   FILE *ed;
   long int no;
   char ch;
   ed=fopen("GAS.DAT","rb+");
   clrscr();
   printline();
   printf("\t\t\t MODIFICATION SCREEN      ");
   printline();
   printf("\n\n\n\t Enter the Customer Number To Modify     : ");
   scanf("%ld",&no);
   while(fread(&r,sizeof(r),1,ed)!=NULL)
    {
       if(r.consno==no)
{
 printf("\n\n\n\t Details of that Number   ");
 printf("\n\t Customer Number        : %ld",r.consno);
 printf("\n\t Customer Name          : %s",r.consname);
 printf("\n\t Customer Address       : %s",r.consadd1);
 printf("\n\t Pincode                : %ld",r.pincode);
 printf("\n\t Telephone Number       : %ld",r.telephone);
 printf("\n\t Date Of Connection     : %s",r.dateofcon);
 printf("\n\t Number of the Cylinder : %ld",r.noofcyln);
 printf("\n\t Cylinder Type          : %c",r.cylntype);
 printf("\n\n\t\t\t\t Press a Key..... ");
 getch();
 clrscr();
 printf("\n\n\n\t Enter New Details to modify  ");
 printf("\n\n\t  Customer Number        : ");
 scanf("%ld",&r.consno);
 printf("\n\t  Customer  Name         : ");
 fflush(stdin);
 gets(r.consname);
 printf("\n\t  Customer's Address     : ");
 gets(r.consadd1);
 printf("\n\t  Pin Code               : ");
 scanf("%ld",&r.pincode);
 printf("\n\t  Telephone Number       : ");
 fflush(stdin);
 scanf("%ld",&r.telephone);
 printf("\n\t  Date Of Connection     : ");
 fflush(stdin);
 gets(r.dateofcon);
 printf("\n\t  Number of the Cylinder : ");
 scanf("%ld",&r.noofcyln);
 printf("\n\t  Cylinder Type          : ");
 fflush(stdin);
 scanf("%c",&r.cylntype);
 fseek(ed,-247L,1);
 fwrite(&r,sizeof(r),1,ed);
 fflush(stdin);
 puts("\n\n\n\t\t\t Record Updated successfully  ");
 getch();
 break;
       }
   }
     if((fread(&r,sizeof(r),1,ed)) == NULL)
     {
clrscr();
printf("\n\n\n\n\n\n\n ");
printline();
printf("\n\n \t\t\t There is NO Record of that number at present.");
printf("\n\n\n\t\t\t Press a key to go to previous Menu");
printf("\n\n");
printline();
getch();
     }

  fclose(ed);
  return;
}


void CEDeletion()
{
   struct custmast r;
   FILE *eb,*temp;
   long int no;
   char ch;
   temp=fopen("TEMP.DAT","wb+");
   eb=fopen("GAS.DAT","rb+");
   clrscr();
   printline();
   printf("\t\t\t\t DELETION SCREEN  ");
   printline();
   printf("\n\n\n\t  Enter the number to be deleted : ");
   scanf("%ld",&no);

   while((fread(&r,sizeof(r),1,eb)) != '\0')
     {
if(r.consno==no)
{
  printf("\n\n");
  printf("\n Details of that Number   \n");
  printf("\n\t  Customer Number       : %ld",r.consno);
  printf("\n\t  Customer Name         : %s",r.consname);
  printf("\n\t  Customer Address      : %s",r.consadd1);
  printf("\n\t  Pincode               : %ld",r.pincode);
  printf("\n\t Telephone Number       : %ld",r.telephone);
  printf("\n\t Date Of Connection     : %s",r.dateofcon);
  printf("\n\t Number of the Cylinder : %ld",r.noofcyln);
  printf("\n\t Cylinder Type          : %c",r.cylntype);
  fflush(stdin);
  printf("\n\n Confirm to Delete this Record [y/n]  : ");
  ch=getchar();
  if(toupper(ch)!= 'Y')
    {
      fwrite(&r,sizeof(r),1,temp);
      continue;
    }
}
else
 {
   fwrite(&r,sizeof(r),1,temp);
 }
    clrscr();
    printf("\n\n\n\n\n\n\n");
    printline();
    printf("\n \t\t\t Records Deleted Successfully.");
    printf("\n\n\n\t\t\t Press a key to go to previous Menu");
    printline();
    getch();

  remove("GAS.DAT");
   rename("TEMP.DAT","GAS.DAT");
   remove("TEMP.DAT");
   fclose(eb);
   fclose(temp);
   return;
   }
}


void CEView()
{
   struct custmast r;
   FILE *as;
   char *s;
   char flag;int i=0;
   as=fopen("GAS.DAT","rb+");
   clrscr();
   while((fread(&r,sizeof(r),1,as)) != NULL)
     {
clrscr();
printline();
printf("\t\t\t\t VIEW SCREEN ");
printline();
printf("\n\n\n\t Details  :");
printf("\n\n\t\t Customer Number        : %ld",r.consno);
printf("\n\t\t Customer Name          : %s",r.consname);
printf("\n\t\t Customer Address       : %s",r.consadd1);
printf("\n\t\t Pincode                : %ld",r.pincode);
printf("\n\t\t Telephone Number       : %ld",r.telephone);
printf("\n\t\t Date Of Connection     : %s",r.dateofcon);
printf("\n\t\t Number of the Cylinder : %ld",r.noofcyln);
printf("\n\t\t Cylinder Type          : %c",r.cylntype);
getch();
     }
   if((fread(&r,sizeof(r),1,as)) == NULL)
     {
clrscr();
printf("\n\n\n\n\n\n\n");
printline();
printf("\n\n \t\t\t There is no (More) Records at present.");
printf("\n\n\n\t\t\t Press a key to go to previous Menu");
printf("\n\n\n");
printline();
getch();
     }
   fclose(as);
   return;
}

void BAddition()
{
  struct booking b;
  FILE *md;
  char flag;
  md=fopen("BOOK.DAT","ab+");
  clrscr();
  do
   {
     clrscr();
     printline();
     printf("\t\t\t\t ADDITION SCREEN \n");
     printline();
     printf("\n\t\n\n Enter the following Details");
     printf("\n\n\t Customer Number    : ");
     scanf("%ld",&b.consno);
     printf("\n\t Customer Name      : ");
     fflush(stdin);
     gets(b.consname);
     printf("\n\t Cylinder Type      : ");
     fflush(stdin);
     scanf("%c",&b.cylntype);
     printf("\n\t Number of Cylinder : ");
     scanf("%ld",&b.noofcyln);
     printf("\n\t Booking Date       : ");
     fflush(stdin);
     gets(b.bookingdate);
     fwrite(&b,sizeof(b),1,md);
     fflush(stdin);
     printf("\n Add one more Records  [y/n] : ");
     flag=getchar();
   }while(toupper (flag)=='Y');
   fclose(md);
  return;
}

void BView()
{
   struct booking b;
   FILE *sd;
   char flag;
   sd=fopen("BOOK.DAT","rb+");
   clrscr();
   while((fread(&b,sizeof(b),1,sd)) != NULL)
    {
       clrscr();
       printline();
       printf("\t\t\t\t VIEW SCREEN       \n");
       printline();
       printf("\n\n\n The details of the booked customers' \n\n\n");
       printf("\n\t\t  Customer Number     : %ld",b.consno);
       printf("\n\t\t  Customer Name       : %s",b.consname);
       printf("\n\t\t  Cylinder Type       : %c",b.cylntype);
       printf("\n\t\t  Number of Cylinder  : %ld",b.noofcyln);
       printf("\n\t\t  Date of Booking     : %s",b.bookingdate);
       getch();
    }
    if((fread(&b,sizeof(b),1,sd)) == NULL)
      {
clrscr();
printf("\n\n\n\n\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
printf("\n\n \t\t There is no (More) Records at present.");
printf("\n\n\n\t\t Press a key to go to previous Menu");
printf("\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
getch();
      }
   fclose(sd);
   return;
}

void BModification()
{
   struct booking b;
   FILE *we;
   long int no,pos;
   char ch;
   we=fopen("BOOK.DAT","rb+");
   clrscr();
   printline();
   printf("\t\t\t MODIFICATION SCREEN   \n");
   printline();
   printf("\n\n\n\t Enter the Customer Number to modify  : ");
   scanf("%ld",&no);
   while(fread(&b,sizeof(b),1,we)!=NULL)
     {
if(b.consno==no)
{
  printf("\n\n The Booking details of that Customer \n");
  printf("\n\t  Customer Number     : %ld",b.consno);
  printf("\n\t  Customer Name       : %s",b.consname);
  printf("\n\t  Cylinder Type       : %c",b.cylntype);
  printf("\n\t  Number of Cylinder  : %ld",b.noofcyln);
  printf("\n\t  Date of Booking     : %s",b.bookingdate);
  printf("\n\n\t\t\t Press a Key ....");
  getch();
  clrscr();
  printf("\n\n\n\t Enter the details to modify ");
  printf("\n\n\t Customer Number    : ");
  scanf("%ld",&b.consno);
  printf("\n\t Customer Name      : ");
  fflush(stdin);
  gets(b.consname);
  printf("\n\t Cylinder Type      : ");
  fflush(stdin);
  scanf("%c",&b.cylntype);
  printf("\n\t Number of Cylinder : ");
  scanf("%ld",&b.noofcyln);
  printf("\n\t Booking Date       : ");
  fflush(stdin);
  scanf("%s",&b.bookingdate);
  fseek(we,-89L,1);
  fwrite(&b,sizeof(b),1,we);
  puts("\n\n\n\t\t\t Records Updated Successfully ");
  getch();
}
     }
   if((fread(&b,sizeof(b),1,we)) == NULL)
      {
clrscr();
printf("\n\n\n\n\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
printf("\n\n \t\t There is no Record of that number at present.");
printf("\n\n\n\t\t Press a key to go to previous Menu");
printf("\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
getch();
      }

   fclose(we);
   return;
}

void BDeletion()
{
    struct booking b;
    FILE *be,*temp;
    long int no;
    char ch;
    temp=fopen("TEMP.DAT","wb+");
    be=fopen("BOOK.DAT","rb+");
    clrscr();
    printline();
    printf("\t\t\t DELETION SCREEN \n");
    printline();
    printf("\n\t Enter the Number to delete : ");
    scanf("%ld",&no);

    while((fread(&b,sizeof(b),1,be)) != NULL)
       {
if(b.consno==no)
  {
     printf("\n\n The details of that customers'\n\n\n");
     printf("\n\t  Customer Number     : %ld",b.consno);
     printf("\n\t  Customer Name       : %s",b.consname);
     printf("\n\t  Cylinder Type       : %c",b.cylntype);
     printf("\n\t  Number of Cylinder  : %ld",b.noofcyln);
     printf("\n\t  Date of Booking     : %s",b.bookingdate);
     fflush(stdin);
     printf("\n\n Confirm to delete this record  [y/n] : ");
     ch=getchar();
     if(toupper(ch)!='Y')
{
 fwrite(&b,sizeof(b),1,temp);
 continue;
}
 }
else
 {
   fwrite(&b,sizeof(b),1,temp);
 }
       }
    clrscr();
    printf("\n\n\n\n\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    printf("\n\n \t\t\t Records Deleted Successfully.");
    printf("\n\n\n\t\t\t Press a key to go to previous Menu");
    printf("\n\n\n\t $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
    getch();
    remove("BOOK.DAT");
    rename("TEMP.DAT","BOOK.DAT");
    remove("TEMP.DAT");
    fclose(be);
    fclose(temp);
    return;
}

void PView()
{
    struct price p;
    FILE *pr;
    pr=fopen("PRICE.DAT","r");
    clrscr();
    while((fread(&p,sizeof(p),1,pr)) != NULL)
    {
       clrscr();
       printline();
       printf("\t\t\t PRICE VIEW SCREEN ");
       printline();
       printf("\n\n\n\t Cylinder Type    : %c",p.cylntype);
       printf("\n\n\t Cylinder's Price : %.2f",p.price);
       getch();
    }
    fclose(pr);
}

void PWork()
{
   struct price p;
   FILE *pr;
   char ch;
   int j=1,k=0;
   pr=fopen("PRICE.DAT","r");
   clrscr();
   printline();
   printf("\t\t\t\t PRICE ENTRY SCREEN ");
   printline();
   printf("\n\n\n");
   while((fread(&p,sizeof(p),1,pr))!=NULL)
   {
       j++;
   }
   fclose(pr);
   if(j==1)
    {
       p.cylntype='D';
       printf("\n\n Enter the amount for Domestic Cylinder : ");
       scanf("%f",&p.price);
       fclose(pr);
       pr=fopen("PRICE.DAT","w");
       fwrite(&p,sizeof(p),1,pr);
       fclose(pr);
    }
  else if(j==2)
    {
       k=1;
       pr=fopen("PRICE.DAT","a");
       p.cylntype='C';
       printf("\n\n\tEnter the price amount for Commercial Cylinder: ");
       scanf("%f",&p.price);
       fwrite(&p,sizeof(p),1,pr);
       fclose(pr);
    }
  else if(j==3)
    {
       pr=fopen("PRICE.DAT","rb+");
       printf("\n\t Select either to modify the price amount of \n\n");
       printf("\t\t\t\t domestic [d] or commercial [c] : ");
       fflush(stdin);
       scanf("%c",&ch);
       if(toupper(ch)=='D')
{
while((fread(&p,sizeof(p),1,pr))  !=  NULL)
 {
   if(toupper(p.cylntype)=='D')
    {
printf("\n\n\tEnter the price  amount for Domestic : ");
scanf("%f",&p.price);
fclose(pr);
pr=fopen("PRICE.DAT","wb+");
fwrite(&p,sizeof(p),1,pr);
fclose(pr);
    }
 }
}
      else
{
 while((fread(&p,sizeof(p),1,pr)) != NULL)
 {
   if(toupper(p.cylntype)=='C')
    {
      printf("\n\n Enter the price amount for Commercial : ");
      fflush(stdin);
      scanf("%f",&p.price);
      fclose(pr);
      pr=fopen("PRICE.DAT","wb+");
      fseek(pr,5,0);
      fwrite(&p,sizeof(p),1,pr);
      fclose(pr);
    }
 }
}
    }
  return;
}

void CustomerReport()
{
   struct transaction  t;
   struct custmast c;
   struct price p;
   long int no;
   char cyln;
   FILE *T,*C,*P;
   T=fopen("TRAN.DAT","rb+");
   C=fopen("GAS.DAT","rb+");
   P=fopen("PRICE.DAT","r");
   clrscr();
   printline();
   printf("\t\t\t CUSTOMER REPORT SCREEN     \n");
   printline();
   printf("\n\t Enter the Customer Number  : ");
   scanf("%ld",&no);
   while((fread(&t,sizeof(t),1,T))  != NULL )
   {
     if(t.consno==no)
       {
 printf("\n\t\t Customer Number : %ld",t.consno);
 printf("\n\t\t Customer Name        : %s",t.consname);
 printf("\n\t\t Customer Address : %s",t.address);
 printf("\n\t\t Pincode : %ld",t.pincode);
 printf("\n\t\t Telephone : %ld",t.telephone);
 printf("\n\t\t Cyln Type : %c",t.cylntype);
 cyln=t.cylntype;
 printf("\n\t\t Booking Date : %s",t.bookingdate);
       }
   }
   while((fread(&c,sizeof(c),1,C)) !=  NULL)
     {
       if(c.consno==no)
{
   printf("\n\t\t Number of Cylinder            : %ld",c.noofcyln);
   printf("\n\t\t Date of Connection            : %s",c.dateofcon);
}
     }
  if(cyln='D')
     {
   fread(&p,sizeof(p),1,P);
   printf("\n\t\t Cylinder's Price               : %f",120.00/*p.price*/);
     }
   else
    {
      while((fread(&p,sizeof(p),1,P))  !=  NULL)
{
 if(p.cylntype=='C')
  {
    printf("\n\t\t Price of the cylinder         : %f",p.price);
  }
       }
    }
   getch();
   fclose(T);
   fclose(P);
   fclose(C);
   return;
}

void DailyTransactionReport()
{
   struct transaction t;
   struct booking b;
   struct stock s;
   FILE *T,*B,*S;
   char *day;
   int i=0,j=0;
   T=fopen("TRAN.DAT","rb+");
   B=fopen("BOOK.DAT","rb+");
   S=fopen("STOCK.DAT","r");
   clrscr();
   printline();
   printf("\t\t DAILY TRANSACTION SCREEN  ");
   printline();

   printf("\n\n\n\tEnter the Date of Release   : ");
   scanf("%s",day);
   printf("\n\n\n");
   while((fread(&t,sizeof(t),1,T))  !=  NULL)
    {
      if(strcmp(strupr(t.releaseddate),strupr(day))==0)
       {
printf("\t\t sl.no         : %ld",t.sino);
printf("\n\t\t customer no     : %ld",t.consno);
printf("\n\t\t cyln type       : %c",t.cylntype);
printf("\n\t\t booking date    : %s",t.bookingdate);
printf("\n\t\t date of release : %s",t.releaseddate);
printf("\n\t\t remarks :%s",t.remark);
    if(t.cylntype=='D')
     {
i++;
     }
    else
     {
j++;
     }
       }
    }
   getch();
   fclose(T);

   clrscr();
   printf("\n\n\n\n DATA ABOUT RELEASED CYLINDER'S\n\n ");
   Hashline();
   printf("\n\n\t\tNo. of Cylinder Released for Domestic Purpose   :%d",i);
   printf("\n\t\tNo. of Cylinder Released for Commercial Purpose :%d",j);

   while((fread(&b,sizeof(b),1,B))  !=  NULL)
   {
      if(strcmp(strupr(b.bookingdate),strupr(day))==0)
      {
     if(b.cylntype=='D')
      {
i++;
      }
     else
      {
j++;
      }
     }
   }
   printf("\n\t\tNo. of Cylinder Booked for Domestic Purpose   :%d",i);
   printf("\n\t\tNo. of Cylinder Booked for Commercial Purpose :%d",j);
   printf("\n");
   Hashline();
   printf("\n\n\n\t\t\t Press a key to Continue...... ");
   getch();

   while((fread(&s,sizeof(s),1,S))  !=  NULL)
    {
      clrscr();
      printf("\n\t\n CURRENT NUMBER OF CYLINDERS ");
      printf("\n\n\n\n\n");
      printline();
      printf("\t\t\t Current Commercial     :%ld",s.ccommercial);
      printf("\n\t\t\t Current Domestic       :%ld",s.cdomestic);
      printline();
    }

   fclose(S);
   fclose(B);
   fclose(T);
   getch();
   return;
}

void WeeklyTransactionReport()
{
   struct transaction t;
   struct booking b;
   struct stock s;
   FILE *T,*B,*S;
   char *day;
   int i=0,j=0;
   T=fopen("TRAN.DAT","rb+");
   B=fopen("BOOK.DAT","rb+");
   S=fopen("STOCK.DAT","r");
   clrscr();
   printline();
   printf("\t\t WEEKLY TRANSACTION SCREEN  ");
   printline();

   printf("\n\n\n\tEnter the Date of Release   : ");
   scanf("%s",day);
   printf("\n\n\n");
   while((fread(&t,sizeof(t),1,T))  !=  NULL)
    {
      if(strcmp(strupr(t.releaseddate),strupr(day))==0)
       {
printf("\t\t sl.no         : %ld",t.sino);
printf("\n\t\t customer no     : %ld",t.consno);
printf("\n\t\t cyln type       : %c",t.cylntype);
printf("\n\t\t booking date    : %s",t.bookingdate);
printf("\n\t\t date of release : %s",t.releaseddate);
printf("\n\t\t remarks :%s",t.remark);
    if(t.cylntype=='D')
     {
i++;
     }
    else
     {
j++;
     }

       }
     }
   getch();
   fclose(T);
   clrscr();
   printf("\n\n\n\n DATA ABOUT RELEASED CYLINDERS' \n\n");
   printline();
   printf("\n\t\tNo. of Cylinder Released for Domestic Purpose   :%d",i);
   printf("\n\t\tNo. of Cylinder Released for Commercial Purpose :%d",j);

   while((fread(&b,sizeof(b),1,B))  !=  NULL)
   {
      if(strcmp(strupr(b.bookingdate),strupr(day))==0)
      {
     if(b.cylntype=='D')
      {
i++;
      }
     else
      {
j++;
      }
     }
   }
   printf("\n\t\tNo. of Cylinder Booked for Domestic Purpose     :%d",i);
   printf("\n\t\tNo. of Cylinder Booked for Commercial Purpose   :%d",j);
   printf("\n");
   printline();
   printf("\n\n\t\t\t\t Press a KEY to continue !!!!!!!! ");
   getch();

   while((fread(&s,sizeof(s),1,S))  !=  NULL)
    {
      clrscr();
      printf("\n\n\n\n");
      printf("\n\n\n\t CURRENT NUMBER OF CYLINDERS' \n ");
      Hashline();
      printf("\n\n");
      printf("\t\t\t Current Commercial   :%ld",s.ccommercial);
      printf("\n\t\t\t Current Domestic     :%ld",s.cdomestic);
      printf("\n");
      Hashline();
    }
   fclose(S);
   fclose(B);
   fclose(T);
   getch();
   return;
}



void printline()
{
int i;
printf("\n\t");
for(i=0;i<62;i++)
{
printf("%c",'*');
}
printf("\n");
return;
}


void Hashline()
{
int i;
printf("\n\t");
for(i=0;i<62;i++)
{
printf("%c",'#');
}
return;
}

void Percentline()
{
int i;
printf("\n\t");
for(i=0;i<62;i++)
{
printf("%c",'%');
}
return;
}

void Addline()
{
int i;
printf("\n\t");
for(i=0;i<62;i++)
{
printf("%c",'!');
}
return;
}

No comments:

Post a Comment