Sunday, 10 December 2017

Pharmacy Management System In C

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()


{
FILE *in;
FILE *out;
char st[25];
printf("\\\********Wel Come Pharmacy Management System********///\n");
printf("Enter the type of transaction\n");
printf("Enter S for stock ! \n");
printf("Enter p for purchase order! \n");
printf("Enter R for Sales Record ! \n");
printf("Enter sO for Supplier Order ! \n");
char ch;
scanf("%c", &ch);
switch(ch)


{
case 's':
case 'S':
//stock detail
printf("\\\\*******Stock Detail********/////// \n");
in = fopen("stock.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);

//enter stock Items
int a;
printf("enter number of medicine\n");
scanf("%d", &a);
out = fopen("stock.txt","w");
int n;
for(n = 0; n<=a; n++)


{
printf("enter medicine name and quantity \n");


gets(st);
fputs(st, out);
fputs("\n", out);


}
fclose(out);

//stock detail
printf("\\\\\\\*******Stock Detail********/////// \n");
in = fopen("stock.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);
break;
case 'p':
case'P':
//stock detail
printf("\\\\\\*******Stock Detail********/////// \n");
in = fopen("stock.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);

//purchase order
char name[25];
int m;
printf("enter number of customer Name\n");
scanf("%s", &name);
printf("enter number of medicine\n");
scanf("%d", &m);



out = fopen("purchase.txt","w");
int c;
for(c = 0; c<=m; c++)


{
printf("enter medicine name and quantity \n");


gets(st);
fputs(st, out);
fputs("\n", out);


}
fclose(out);

//customer order
printf("\\\\\\*******Purchase Order********/////// \n");
in = fopen("purchase.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);

//sales record update
out = fopen("salesRecord.txt","a");
fprintf(out, "%s %d \n", name, m);


fclose(out);
break;
case 'R':
case'r':
printf("\\\\\\*******Sales History********/////// \n");
in = fopen("salesRecord.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);
break;
case 'o':
case'O':
//read stock record
printf("\\\\*******Stock Detail********/////// \n");
in = fopen("stock.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);

printf("||****enter the order to supplier ****||\n");



//supplier order
int x;
printf("enter number of medicine\n");
scanf("%d", &x);
out = fopen("supplier.txt","w");
int i;
for(i = 0; i<=x; i++)


{
printf("enter medicine name and quantity \n");


gets(st);
fputs(st, out);
fputs("\n", out);


}
fclose(out);

//supplier order show
printf("\\\\\\*******suuplier Order complete list*******//////");
in = fopen("supplier.txt","r");
while(fgets(st, 25, in) != NULL)


{
printf("%s \n", st);


}
fclose(in);

break;
default:
printf("Sorry! you enter the invalid character for transaction!!\n");
printf("So, Please enter the above mentioned character!!");


}
getch();

}

0 comments:

Post a Comment

Tech UOG