Ticker

6/recent/ticker-posts

C LANGUAGE PROJECT (MEDICAL STORE)

C LANGUAGE PROJECT




MEDICAL STORE - PROJECT

/* ------- Files details -------
1. Stock_details.dat (File used to store stock item details)
2. Sales_details.dat (File used to store sales details)
*/

#include<stdio.h>
#include<conio.h>
#include<process.h>

//Function declarations
void main_menu();
void insert_record();
void sales_details();
void sales_report();
void stock_details();

// Definition of main function
void main()
{
clrscr();
int c;
char ch;
do
{
main_menu();

printf("\n\nEnter your choice (1-5):");
scanf("%d",&c);

// Calling funtion by switch statement
switch(c)
{
case 1:
insert_record(); break;
case 2:
sales_details(); break;
case 3:
sales_report(); break;
case 4:
stock_details(); break;
case 5:
exit(0);
default:
printf("Wrong choice, try again");
}

printf("\n\n\n\nDo you want to continue (y/n):");
ch=getche();
}while(ch=='y' || ch=='Y');
getch();
}

//Define menu details funtcion
void main_menu ()
{
clrscr();
printf("\n\t\t\t---------------------------\n");
printf("\t\t\t* * * Bhavesh Medico * * *");
printf("\n\t\t\t---------------------------\n");

printf("\n\n\n----- Insert Records -----\n");
printf("1. New Medicine");
printf("\n2. New Sales");

printf("\n\n\n----- Reports -----\n");
printf("3. Sales");
printf("\n4. Stock");

printf("\n\n\n----- Exit Function -----\n");
printf("5. Exit");
}

//Define menu details funtcion
void insert_record()
{
int m_id,price;
char m_name[20], brand[40];
char m_date[20], e_date[40];

printf("Enter medicine no:");
scanf("%d",&m_id);
printf("Enter medicine  name:");
scanf("%s",m_name);
printf("Enter company/brand name:");
scanf("%s",brand);
printf("Enter price:");
scanf("%d",&price);
printf("Enter manufacturing date:");
scanf("%s",m_date);
printf("Enter expiry date:");
scanf("%s",e_date);

FILE *ob;
ob=fopen("stock_details.dat","a");
fprintf(ob,"\n%d",m_id);
fprintf(ob,"\t%s",m_name);
fprintf(ob,"\t%s",brand);
fprintf(ob,"\t%d",price);
fprintf(ob,"\t%s",m_date);
fprintf(ob,"\t%s",e_date);
fclose(ob);

}

//Define menu details funtcion
void sales_details()
{
int price,q;
char date[20], brand[20];
char item_name[20], buyer_name[40];

printf("\nAvailable stocks.....\n");
stock_details();
printf("Enter date (MM/DD):");
scanf("%s",&date);
printf("Enter customer name:");
scanf("%s",&buyer_name);
printf("Enter item name:");
scanf("%s",&item_name);
printf("Enter item price:");
scanf("%d",&price);
printf("Enter quantity:");
scanf("%d",&q);

FILE *ob;
ob=fopen("sales_details.dat","a");
fprintf(ob,"\n%s",date);
fprintf(ob,"\t%s",buyer_name);
fprintf(ob,"\t\t%s",item_name);
fprintf(ob,"\t\t  %d",q);
fprintf(ob,"\t\t%d",(q*price));

fclose(ob);
}

//Define menu details funtcion
void sales_report()
{
char ch;
FILE *ob;
ob=fopen("sales_details.dat","r");
if(ob==NULL)
{
printf("No Records found");
}
else
{
printf("\n---------------------------------------------------------------");
printf("\nDate\tCust.Name\tItem name\tQuant.\t     Total price");
printf("\n---------------------------------------------------------------\n");

while((ch=fgetc(ob))!=EOF)
{
printf("%c",ch);
}
fclose(ob);
}
}

//Define menu details funtcion
void stock_details()
{
char ch;
FILE *ob;
ob=fopen("stock_details.dat","r");
if(ob==NULL)
{
printf("No Record found");
}

printf("\n----------------------------------------------------------");
printf("\nCode \tName \tBrand \tPrice \tManuf.Date \tExp.Date");
printf("\n----------------------------------------------------------\n");

while((ch=fgetc(ob))!=EOF)
{
printf("%c",ch);
}
printf("\n----------------------------------------------------------\n");

fclose(ob);
}






Post a Comment

0 Comments