Upload
vinod-verma
View
221
Download
0
Embed Size (px)
Citation preview
8/14/2019 Inventry Management in c
1/52
PAGE:1
C PROGRAMMING
Term paper ofc PROGRAMMING..
CSE :202
TERM PAPER TOPIC:-inventry MANAGEMENTSYSTEM..!!
SUBMITTED TO: SUBMITTED
BY:
Mr.DEEPAK VISHWAKARMA vinod verma
SEC.-c2802B33
8/14/2019 Inventry Management in c
2/52
PAGE:2
C PROGRAMMING
REG.-
10804863
8/14/2019 Inventry Management in c
3/52
PAGE:3
C PROGRAMMING
ACKNOWLEDGEMENT
First and foremost I thank my teacher Mr.
DEEPAK VISHWAKARMA has assigned me
this term paper to bring out my creative
capabilities.I express my gratitude to my parents for being a
continuous source of encouragement for all their
financial aid.
I would like to acknowledge the assistance
provided to me by the library staff of LOVELY
PROFESSIONAL UNIVERSITY.
My heartfelt gratitude to my class-mates and for
helping me to complete my work in time.
VINOD VERMA
8/14/2019 Inventry Management in c
4/52
PAGE:4
C PROGRAMMING#include
#include
#include
#include
#include
#include
#include
#include
#include
void show_mouse();
int t();
void edit();
void infor();
void entry();
void display();
void search();void search_id();
void search_name();
void del();
void deletion();
void deletion_id();
void print();
void help();
void eat();
void general();
void exit();
8/14/2019 Inventry Management in c
5/52
PAGE:5
C PROGRAMMINGvoid seteefect(int, int);
void graph();
void bar(int inscor);
void graph2();
void bar2(int inscore2);
void report();
void report2();
void report3();
void pur();
void graph1();
void design();
void bbox();
void ventry(char t[],int);
struct shop
{char desc[20];
int rack;
char ch;
int cabnit;
int quantity;
float sale;
char id[6];
float total;
float unit;
float cost;
8/14/2019 Inventry Management in c
6/52
PAGE:6
C PROGRAMMINGfloat profit;
float bye;
int qty;
int ost;
int b;
};
struct shop temp;
struct shop x[20];
FILE *ptr;
//int age;
char a[10];
/************************************displays information about thecars***************************/
void infor()
{
int sher;
clrscr();
textcolor(WHITE);
gotoxy(13,3);
printf("\xDB\xDB\xDB\xDB\xB2 INFORMATION ABOUT PRODUCTS\xB2\xDB\xDB\xDB\xDB");
gotoxy(2,5);
printf("THIS SECTION IS TO TELL WHAT KIND OF PRODUCTS ARE THERE IN STORE");
printf("\n\nENTER THE OPTION WHICH SUITS YOU.\n");
printf("\n\n1.EDIBLES.\n\n");
8/14/2019 Inventry Management in c
7/52
PAGE:7
C PROGRAMMINGprintf("\n2.GENERAL ITEMS.\n\n");
printf("\n\n\n\n\nOPTION:");
sher=toupper(getch());
//
switch(sher)
{
case '1':
eat();
break;
case '2':
general();
break;
default:gotoxy(8,21);
cprintf("\awrong entry press any key to go main menu..");
}
getche();
}
void eat()
{
clrscr();
8/14/2019 Inventry Management in c
8/52
PAGE:8
C PROGRAMMINGprintf("***************************************************************\n");
printf(" ID : 123. JAM COMPANY : MITUCHELS RACK NO 24 \n");
printf(" ID : 124. HONEY COMPANY : PAK PURE RACK NO 25\n");
printf(" ID : 125. MILK COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 126. BREAD COMPANY : WONDER RACK NO 27\n");
printf(" ID : 127. CHEES COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 128. JUICE COMPANY : SONS RACK NO 29\n");
printf(" ID : 129. PEPSI COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 130. BUTTER COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 131. ICECREAM COMPANY : POLKA FREEZER 32 \n");
printf("**************************************************************\n\n");
printf("Press any key to continue......");
getche();
clrscr();
printf(" ID : 133. MILO COMPANY : MITUCHELS RACK NO 24 \n");
printf(" ID : 134. KEY BRAN COMPANY : PAK PURE RACK NO 25\n"); printf(" ID : 135. TANG COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 136. ALWAYS COMPANY : WONDER RACK NO 27\n");
printf(" ID : 327. PEPPARS COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 138. JHERBAL COMPANY : SONS RACK NO 29\n");
printf(" ID : 139. PEPSI COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 130. ORAGD COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 131. ICECREAM COMPANY : POLKA FREEZER 32 \n");
printf("**************************************************************\n");
printf(" ID : 143. SHAMPO COMPANY : MITUCHELS RACK NO 24 \n");
printf(" ID : 144. AGRI COMPANY : PAK PURE RACK NO 25\n");
8/14/2019 Inventry Management in c
9/52
PAGE:9
C PROGRAMMING printf(" ID : 145. TIMO COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 146. WASHSN COMPANY : WONDER RACK NO 27\n");
printf(" ID : 147. LACE COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 428. YARDLY COMPANY : SONS RACK NO 29\n");
printf(" ID : 149. MUSK COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 140. BUTTER COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 141. IMPERIAL COMPANY : POLKA FREEZER 32 \n");
printf("**************************************************************\n");
printf("\n\nPress enter to return to main menu");
}
void general()
{
clrscr();
printf("***************************************************************\n");
printf(" ID : 153. DETOL COMPANY : MITUCHELS RACK NO 24 \n"); printf(" ID : 154. SHAMPO COMPANY : PAK PURE RACK NO 25\n");
printf(" ID : 155. FINERRE COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 156. CURTIS COMPANY : WONDER RACK NO 27\n");
printf(" ID : 157. NIVKA COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 158. NIVCA COMPANY : SONS RACK NO 29\n");
printf(" ID : 159. DETOL COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 150. BUTTER COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 151. SHAVE COMPANY : POLKA FREEZER 32 \n");
printf("***************************************************************\n\n");
printf("Press any key to continue......");
8/14/2019 Inventry Management in c
10/52
PAGE:10
C PROGRAMMINGgetche();
clrscr();
printf(" ID : 163. ADDIS COMPANY : MITUCHELS RACK NO 24 \n");
printf(" ID : 164. SKIN COMPANY : PAK PURE RACK NO 25\n");
printf(" ID : 165. MAX COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 166. BRESCO COMPANY : WONDER RACK NO 27\n");
printf(" ID : 167. ZABIT COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 168. COPEX COMPANY : SONS RACK NO 29\n");
printf(" ID : 169. SOAP COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 160. PAMOLI COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 161. AVA COMPANY : POLKA FREEZER 32 \n");
printf("***************************************************************\n");
printf(" ID : 163. CAMY COMPANY : MITUCHELS RACK NO 24 \n");
printf(" ID : 164. SAFE COMPANY : PAK PURE RACK NO 25\n");
printf(" ID : 165. GUARD COMPANY : HALEEB RACK NO 26\n");
printf(" ID : 166. DOVE COMPANY : WONDER RACK NO 27\n"); printf(" ID : 167. REXONA COMPANY : JUNAID RACK NO 28\n");
printf(" ID : 168. TOUCNME COMPANY : SONS RACK NO 29\n");
printf(" ID : 169. FORHANS COMPANY : MAJEED RACK NO 30 \n");
printf(" ID : 160. SIGNAL2 COMPANY : JAFFAR RACK NO 31 \n");
printf(" ID : 161. CLOSEUP COMPANY : POLKA FREEZER 32 \n");
printf("***************************************************************\n");
printf("\n\nPress enter to return to main menu");
}
8/14/2019 Inventry Management in c
11/52
PAGE:11
C PROGRAMMING/////////////////////////////// time ///////////////////////////
int t(void)
{
time_t t;
time(&t);
// clrscr();
gotoxy(15,21);
printf("Date and time: %s\n", ctime(&t));
return 0;
}
///////////////////////////////////// validation //////////////////////////
void ventry(char t[],int code)
{
int i=0;if(code==0)
{
while((t[i]=getch())!='\r' && i=97 && t[i]=65 && t[i]
8/14/2019 Inventry Management in c
12/52
PAGE:12
C PROGRAMMING{
while((t[i]=getch())!='\r' && i=48 && t[i]
8/14/2019 Inventry Management in c
13/52
8/14/2019 Inventry Management in c
14/52
PAGE:14
C PROGRAMMINGgotoxy(7,13);
///////////////////////
cprintf("\xDB\xDB\xB2 ENTER UNIT COST :$ ");
ventry(a,1);
temp.unit= atof(a);
flushall();
gotoxy(7,15);
cprintf("\xDB\xDB\xB2 ENTER SALE PRICE :$ ");
ventry(a,1);
temp.sale= atof(a);
flushall();
gotoxy(7,17);
cprintf("\xDB\xDB\xB2 ENTER QUANTITY : ");
ventry(a,1);temp.quantity= atoi(a);
flushall();
gotoxy(7,18);
cprintf("=====================================");
temp.total=temp.quantity*temp.sale;
textcolor(10);
gotoxy(10,20);
cprintf("\xB2\xDB\xB2 TOTAL PRICE = $ %.2f",temp.total);
8/14/2019 Inventry Management in c
15/52
PAGE:15
C PROGRAMMINGtemp.cost=(temp.unit*temp.quantity);
gotoxy(40,20);
cprintf("\xDB\xB2 TOTAL COST = $ %.2f",temp.cost);
}
fwrite(&temp,sizeof(temp),1,ptr);
textcolor(10);
gotoxy(10,23);
cprintf("More entries [y/n]");
ch=getche();
}
fclose(ptr);
}
/*****************************data retreivel********************************/
void display()
{
clrscr();
ptr=fopen("shop.dat","rb");
while ((fread(&temp,sizeof(temp),1,ptr))==1)
{
8/14/2019 Inventry Management in c
16/52
PAGE:16
C PROGRAMMINGgotoxy(22,3);
printf("\xDB\xDB\xDB\xB2\xB2 RETRIEVE RECORD \xB2\xB2\xDB\xDB\xDB");
gotoxy(18,5);
printf("\xDB\xDB\xB2 DESCRIPTION : %s",temp.desc);
gotoxy(18,7);
printf("\xDB\xDB\xB2 ID NUMBER : %s",temp.id);
gotoxy(18,9);
printf("\xDB\xDB\xB2 RACK NO : %d",temp.rack);
gotoxy(18,11);
printf("\xDB\xDB\xB2 CABINET NO : %d",temp.cabnit);
gotoxy(18,13);
printf("\xDb\xDB\xB2 UNIT COST :$ %.2f",temp.unit);
gotoxy(18,15);
printf("\xDB\xDB\xB2 SALE PRICE : $ %.2f",temp.sale);
gotoxy(18,17);
printf("\xDB\xDB\xB2 QUANTITY : %d",temp.quantity);gotoxy(16,18);
printf("===================================");
gotoxy(16,20);
printf("\xDB\xDB\xB2 TOTAL PRICE : $ %.2f",temp.total);
gotoxy(47,20);
printf("\xDB\xB2 TOTAL COST : $ %.2f",temp.cost);
gotoxy(20,23);
printf("Press Enter to see next if any or exit ...");
getche();
8/14/2019 Inventry Management in c
17/52
PAGE:17
C PROGRAMMINGclrscr();
}
fclose(ptr);
//
}
/*******************************data search*******************************/
void search()
{
int sh;
clrscr();
design();gotoxy(17,6);
printf("\xDB\xDB\xB2 Two options available to search \xB2\xDB\xDB");
gotoxy(15,9);
printf("[ 1 ] - Search by ID number .");
gotoxy(15,11);
printf("[ 2 ] - Search by Description .");
gotoxy(17,15);
printf("Enter your choice:: ");
sh=toupper(getch());
8/14/2019 Inventry Management in c
18/52
PAGE:18
C PROGRAMMINGswitch(sh)
{
case '1':
search_id();
break;
case '2':
search_name();
break;
default:
gotoxy(18,18);
printf("\a\xDB\xDB wrong entry try again");
getch();
}
getche();
}
/*****************************search by id*********************************/
void search_id()
{
int flag=0;
char lkf[20];
8/14/2019 Inventry Management in c
19/52
PAGE:19
C PROGRAMMINGclrscr();
ptr=fopen("shop.dat","rb");
design();
gotoxy(13,4);
printf("\xDB\xDB\xB2 Enter id to be searched:");
scanf("%s",&lkf);
while((!flag)&&(fread(&temp,sizeof(temp),1,ptr))==1)
{
if(strcmp(temp.id,lkf)==0)
flag=1;
}
if(flag)
{
gotoxy(18,6);printf("Product ID : %s",temp.id);
gotoxy(18,8);
printf("Description : %s",temp.desc);
gotoxy(18,10);
printf("Rack no : %d",temp.rack);
gotoxy(18,12);
printf("Cabnit : %d",temp.cabnit);
gotoxy(18,14);
printf("Sale price :$ %.2f",temp.sale);
gotoxy(18,16);
8/14/2019 Inventry Management in c
20/52
PAGE:20
C PROGRAMMINGprintf("Quantity : %d",temp.quantity);
gotoxy(16,17);
printf("============================");
gotoxy(18,19);
printf(" Total :$ %.2f",temp.total);
}
else
printf("Record not found!");
fclose(ptr);
}
/*****************************search by name******************************/
void search_name(){
int flag=0;
char lkf[20];
clrscr();
ptr=fopen("shop.dat","rb");
design();
gotoxy(13,4);
printf("\xDB\xDB\xB2 Enter description to be searched:");
scanf("%s",&lkf);
while((!flag)&&(fread(&temp,sizeof(temp),1,ptr))==1)
8/14/2019 Inventry Management in c
21/52
PAGE:21
C PROGRAMMING{
if(strcmp(temp.desc,lkf)==0)
flag=1;
}
if(flag)
{
gotoxy(18,6);
printf("Product ID : %s",temp.id);
gotoxy(18,8);
printf("Description : %s",temp.desc);
gotoxy(18,10);
printf("Rack no : %d",temp.rack);
gotoxy(18,12);
printf("Cabnit : %d",temp.cabnit);gotoxy(18,14);
printf("Sale price :$ %.2f",temp.sale);
gotoxy(18,16);
printf("Quantity : %d",temp.quantity);
gotoxy(16,17);
printf("============================");
gotoxy(18,19);
printf(" Total :$ %.2f",temp.total);
8/14/2019 Inventry Management in c
22/52
PAGE:22
C PROGRAMMING}
else
printf("Record not found!");
fclose(ptr);
}
/******************************data deletion*****************************/
void deletion()
{
int j,n,i;
char tar[30];
int count=0;
ptr = fopen("shop.dat","rb");
clrscr();design();
gotoxy(17,10);
printf("\xDB\xDB Enter Description to be deleted:");
scanf("%s",&tar);
j=0;
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
if((strcmp(temp.desc,tar)0))
{
8/14/2019 Inventry Management in c
23/52
PAGE:23
C PROGRAMMINGx[j] = temp;
j++;
}
else
{
count++;
}
}
if (count==0)
{
clrscr();
design();
gotoxy(30,10);
printf("\xDB\xDB Record Not Found");
gotoxy(17,23);
printf("Press Enter to go to MAIN MENU .....");getch();
return;
}
fclose(ptr);
n = j;
clrscr();
ptr=fopen("shop.dat","wb");
for(i=0; i
8/14/2019 Inventry Management in c
24/52
PAGE:24
C PROGRAMMINGfclose(ptr);
clrscr();
design();
gotoxy(20,10);
printf("Record has been deleted");
gotoxy(20,12);
printf("Check it by going to the displayed record");
gotoxy(17,23);
printf("Press Enter to go to MAIN MENU ......");
getch();
}
/******************************data print*********************************/
void print()
{
clrscr();
putc('\n',stdprn);
fputs("\n\t\t\tREPRT OF SALES",stdprn);
putc('\n',stdprn);
fputs("===========================",stdprn);
putc('\n',stdprn);
putc('\n',stdprn);
fputs("PRODUCT ID. NAME. SALE PRICE. QUANTITY. TOTAL PRICE",stdprn);
8/14/2019 Inventry Management in c
25/52
PAGE:25
C PROGRAMMINGfputs("===================================================================",st
dprn);
putc('\n',stdprn);
putc('\n',stdprn);
ptr=fopen("shop.dat","rb");
while( (fread(&temp,sizeof(temp),1,stdprn))==1)
{
fprintf(stdprn," %s",temp.id);
fprintf(stdprn,"\t%s",temp.desc);
fprintf(stdprn,"\t%.2f",temp.sale);
fprintf(stdprn,"\t%ld\n",temp.quantity);
fprintf(stdprn,"\t%.2f",temp.total);
}
fclose(ptr);
}
/******************************help***************************************/
void help()
{
clrscr();
design();
textcolor(WHITE);
gotoxy(20,4);
cprintf("\xDB\xDB\xDB\xDB\xB2 HELP ABOUT THE PROGRAM \xB2\xDB\xDB\xDB\xDB");
8/14/2019 Inventry Management in c
26/52
PAGE:26
C PROGRAMMINGgotoxy(4,6);
cprintf(" [ 2 ] - ENTER RECORDS : THIS OPTION ALLOWS THE USER TO ENTER NEW ");
gotoxy(30,7);
cprintf("RECORDS. USER ENTERS PRODUCT ID, DESCRIPTION,");
gotoxy(30,8);
cprintf("QUANTITY AND UNIT PRICE. THE PROGRAMM CALCULATES");
gotoxy(30,9);
cprintf("TOTAL PRICE AND DISPLAYS ON THE SCREEN.");
gotoxy(4,11);
cprintf(" [ 3 ] - ENTER SALES : THIS OPTION ALLOWS THE USER TO SEE PREVIOUS ");
gotoxy(30,12);
cprintf("SALE RECORDS.");
gotoxy(4,14);
cprintf(" [ 4 ] - SEARCH PURCHASE : THIS OPTION ALLOWS THE USER TO SEARCHSPECIFIC");
gotoxy(30,15);
cprintf("RECORD BY ENTERING ID OR 'DESCRIPTION'");
gotoxy(4,17);
cprintf(" [ 5 ] - DELETE PURCHASE : THIS OPTION ALLOWS THE USER TO DELETE ASPECIFIC");
gotoxy(30,18);
cprintf("RECORD BY ENTERING ITS 'DESCRIPTION' OR ID");
gotoxy(6,23);
cprintf("Press any key to continue .............");
getche();
clrscr();
8/14/2019 Inventry Management in c
27/52
PAGE:27
C PROGRAMMINGdesign();
textcolor(WHITE);
gotoxy(4,5);
cprintf(" [ 6 ] - VIEW REPORT : THIS OPTION ALLOWS THE USER TO PRINT PREVIOUS");
gotoxy(30,6);
cprintf("SALE RECORDS ON PRINTER");
gotoxy(4,8);
cprintf(" [ 7 ] - PRINT RECORDS : THIS OPTION ALLOWS THE USER TO PRINT RECORDS");
gotoxy(30,9);
cprintf("OM PRINTER.");
gotoxy(4,11);
cprintf(" [ 8 ] - VIEW GRAPH : THIS OPTION ALLOWS THE USER TO VIEW GRAPH ");
gotoxy(30,12);
cprintf("OF QUANTITY.");
gotoxy(10,23);
printf("Press any key to go to the MAIN MENU ........");
getche();
}
/***************************main menu*************************************/
menu()
{
int x;
do{
8/14/2019 Inventry Management in c
28/52
PAGE:28
C PROGRAMMING{
clrscr();
design();
t();
textcolor(WHITE);
gotoxy(24,3);
cprintf("\xDB\xDB\xDB\xDB\xB2 LYDIA'S DEPARTMENT STORE\xB2\xDB\xDB\xDB\xDB");
gotoxy(3,4);
cprintf("--------------------------------------------------------------------------");
gotoxy(35,5);
cprintf("MAIN MENU");
gotoxy(26,8);
cprintf(" 1 - INFORMATION ABOUT PRODUCTS ");
gotoxy(26,9);
cprintf(" 2 - ENTER PURCHASE RECORDS ");
gotoxy(26,10);
cprintf(" 3 - ENTER PRODUCTS TO BE SALE ");
gotoxy(26,11);
cprintf(" 4 - SEARCH FOR RECORD ");
gotoxy(26,12);
cprintf(" 5 - DELETE RECORD FROM STORE DATABASE ");
gotoxy(26,13);
cprintf(" 6 - VIEW SALES , PURCHASE & PROFIT REPORT ");
gotoxy(26,14);
cprintf(" 7 - PRINT RECORDS ");
gotoxy(26,15);
8/14/2019 Inventry Management in c
29/52
PAGE:29
C PROGRAMMINGcprintf(" 8 - BAR GRAPH OF QUANTITY / PROFIT ");
gotoxy(26,16);
cprintf(" 9 - RETRIEVE INFORMATION ");
gotoxy(26,17);
cprintf(" H - HELP ");
gotoxy(26,18);
cprintf(" E - EXIT ");
gotoxy(26,23);
//
cprintf("ENTER YOUR CHOICE :: ");
gotoxy(47,23);
x=toupper(getch());
switch(x)
{
case '1':
infor();break;
case '2':
entry();
break;
case '3':
edit();
break;
8/14/2019 Inventry Management in c
30/52
PAGE:30
C PROGRAMMINGcase '4':
search();
break;
case '5':
del();
break;
case '6':
report2();
break;
case '7':
print();
break;
case 'h': case'H':
help();
break;
case'8':
graph1();
break;
case '9':
display();
8/14/2019 Inventry Management in c
31/52
8/14/2019 Inventry Management in c
32/52
PAGE:32
C PROGRAMMING
void graph()
{
int inscor=1;
char ch;
clrscr();
design();
gotoxy(20,23);
printf("Press enter to go to MAIN MENU .....");
textcolor(10);
gotoxy(15,4);
cprintf("************* GRAPH OF PRODUCT QUANTITY *************");
textcolor(14);
gotoxy(3,5);
cprintf(" PRODUCT NAME");
ptr=fopen("shop.dat","rb");while((fread(&temp,sizeof(temp),1,ptr))==1)
{
printf("\n \xBA %s \t:",temp.desc);
bar(inscor);
}
fclose(ptr);
getche();
8/14/2019 Inventry Management in c
33/52
PAGE:33
C PROGRAMMING}
void bar()
{
int j;
for(j=1;j
8/14/2019 Inventry Management in c
34/52
PAGE:34
C PROGRAMMINGptr=fopen("shop.dat","rb");
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
//
printf("\n \xBA %s\t",temp.id);
printf("\t%s",temp.desc);
printf("\t\t$%.2f",temp.sale);
// printf("\t\t%d",temp.qty);
printf("\t\t%d",temp.quantity);
// printf("\t\t%d",temp.bye);
printf("\t\t $%.2f",temp.total);
}
getche();}
void seteffect(int b, int f)
{
clrscr();
textbackground(b);
textcolor(f);
}
/********************************** purchase report **********************/
8/14/2019 Inventry Management in c
35/52
PAGE:35
C PROGRAMMINGvoid pur()
{
char ch;
clrscr();
design();
show_mouse();
gotoxy(20,23);
printf("Press Enter to go to MAIN MENU ...........");
textcolor(GREEN);
gotoxy(25,4);
cprintf("\xDB\xDB\xDB\xDB\xDB\xB2 VIEW OF PURCHASES \xB2\xDB\xDB\xDB\xDB\xDB");
textcolor(RED);
gotoxy(4,7);
cprintf("PRODUCT ID. NAME. UNIT PRICE. QUANTITY. TOTAL COST");
gotoxy(4,9);
printf("========================================================================");
ptr=fopen("shop.dat","rb");
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
//
printf("\n \xBA %s\t\t",temp.id);
printf(" %s",temp.desc);
printf("\t\t$%.2f",temp.unit);
printf("\t\t%d",temp.quantity);
8/14/2019 Inventry Management in c
36/52
8/14/2019 Inventry Management in c
37/52
PAGE:37
C PROGRAMMINGbar2(inscor2);
}
fclose(ptr);
getche();
}
void bar2()
{
int j;
temp.profit=(temp.total-temp.cost);
//
for(j=1;j
8/14/2019 Inventry Management in c
38/52
PAGE:38
C PROGRAMMINGgotoxy(24,3);
printf("\xDB\xDB\xDB\xDB\xB2 BAR GRAPH \xB2\xDB\xDB\xDB\xDB");
gotoxy(10,5);
printf("THIS SECTION IS TO show the graph of quantity and profit ");
printf("\n\n\t ********* ENTER THE OPTION WHICH SUITS YOU. *******\n");
printf("\n\n\t\xDB\xDB\xB2 1.QUANTITY.\n\n");
printf("\n\t\xDB\xDB\xB2 2.PROFIT.\n");
printf("\n\n\n\t\t\xDB\xDB\xB2 OPTION:");
sher=toupper(getch());
switch(sher)
{
case '1':
graph();
break;
case '2':
graph2();
break;
default:
gotoxy(9,20);
textcolor(RED);
cprintf("\a\xDB\xB2 WRONG ENTRY : PRESS ENTER TO GO TO MAIN MENU... ");
getche();
}
8/14/2019 Inventry Management in c
39/52
PAGE:39
C PROGRAMMING
}
/************************** report of profit **********************/
void report3()
{
char ch;
clrscr();
design();
gotoxy(20,23);
printf("Press Enter to go to MAIN MENU .... ");
textcolor(GREEN);
gotoxy(25,4);
cprintf("\xDB\xDB\xDB\xDB\xDB\xB2 VIEW OF PROFIT \xB2\xDB\xDB\xDB\xDB\xDB");
textcolor(RED);
gotoxy(4,7);cprintf("PRODUCT ID. DESCRIPTION. QUANTITY. PROFIT.");
gotoxy(4,9);
printf("============================================================");
ptr=fopen("shop.dat","rb");
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
printf("\n \xBA %s.",temp.id);
printf("\t\t%s",temp.desc);
8/14/2019 Inventry Management in c
40/52
PAGE:40
C PROGRAMMINGprintf("\t\t%d",temp.quantity);
temp.profit=(temp.total-temp.cost);
printf("\t\t $%.2f",temp.profit);
}
getche();
}
/************************* SALE , PURCHASE AND PROFIT REPORTCALL***************/
void report2()
{
int sher;
clrscr();
bbox();
textcolor(WHITE);
gotoxy(21,3);
printf("\xDB\xDB\xDB\xDB\xB2 REPORT OF SALES / PURCHASE \xB2\xDB\xDB\xDB\xDB");
gotoxy(5,5);
printf("\tTHIS SECTION IS VIEWING SALES, PURCHASE and PROFIT REPORTS ");
gotoxy(10,7);
printf(" ********* ENTER THE OPTION WHICH SUITS YOU. **********\n");
gotoxy(12,10);
printf("\xDB\xDB\xB2 1.SALES.");
gotoxy(12,12);
8/14/2019 Inventry Management in c
41/52
PAGE:41
C PROGRAMMINGprintf("\xDB\xDB\xB2 2.PURCHASE.");
gotoxy(12,14);
printf("\xDB\xDB\xB2 3.PROFIT.");
gotoxy(14,17);
printf("\xDB\xDB\xB2 OPTION:");
sher=toupper(getch());
switch(sher)
{
case '1':
report();
break;
case '2':
pur();break;
case '3':
report3();
break;
default:
gotoxy(9,20);
textcolor(RED);
cprintf("\a\xDB\xB2 WRONG ENTRY : PRESS ENTER TO GO TO MAIN MENU....");
8/14/2019 Inventry Management in c
42/52
8/14/2019 Inventry Management in c
43/52
PAGE:43
C PROGRAMMINGgotoxy(2,9);cprintf("\xBA");gotoxy(2,10);cprintf("\xBA");gotoxy(2,11);cprintf("\xBA");gotoxy(2,12);cprintf("\xBA");
gotoxy(2,13);cprintf("\xBA");gotoxy(2,14);cprintf("\xBA");gotoxy(2,15);cprintf("\xBA");gotoxy(2,16);c
printf("\xBA");
gotoxy(2,17);cprintf("\xBA");gotoxy(2,18);cprintf("\xBA");gotoxy(2,22);cprintf("\xCC");
gotoxy(2,19);cprintf("\xBA");gotoxy(2,20);cprintf("\xBA");gotoxy(2,21);cprintf("\xBA");gotoxy(2,24);cprintf("\xC8");
gotoxy(2,23);cprintf("\xBA");
gotoxy(3,24);
for(i=1;i
8/14/2019 Inventry Management in c
44/52
PAGE:44
C PROGRAMMINGgotoxy(77,9);cprintf("\xBA");gotoxy(77,10);cprintf("\xBA");gotoxy(77,11);cprintf("\xBA");gotoxy(77,12);cprintf("\xBA");
gotoxy(77,13);cprintf("\xBA");gotoxy(77,14);cprintf("\xBA");gotoxy(77,15);cprintf("\xBA");gotoxy(77,
16);cprintf("\xBA");
gotoxy(77,17);cprintf("\xBA");
textcolor(RED);
//
}
void bbox()
{
int c,r;
for(c=1;c
8/14/2019 Inventry Management in c
45/52
PAGE:45
C PROGRAMMING}
}
////////////////////////////////// by id deletion ////////////////////////////
void deletion_id()
{
int j,n,i;
char tar[30];
int count=0;
ptr = fopen("shop.dat","rb");
clrscr();
design();
gotoxy(15,8);printf("\xDB\xDB Enter ID be deleted:");
scanf("%s",&tar);
j=0;
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
if((strcmp(temp.id,tar)0))
{
x[j] = temp;
j++;
8/14/2019 Inventry Management in c
46/52
PAGE:46
C PROGRAMMING}
else
{
count++;
}
}
if (count==0)
{
clrscr();
design();
gotoxy(30,10);
printf("\xDB\xDB Record Not Found");
gotoxy(17,23);
printf("Press Enter to go to MAIN MENU ......");
getch();
return;}
fclose(ptr);
n = j;
clrscr();
ptr=fopen("shop.dat","wb");
for(i=0; i
8/14/2019 Inventry Management in c
47/52
8/14/2019 Inventry Management in c
48/52
PAGE:48
C PROGRAMMINGsh=toupper(getch());
switch(sh)
{
case '1':
deletion_id();
break;
case '2':
deletion();
break;
default:
gotoxy(18,18);
printf("\a\xDB\xDB Wrong entry ");
gotoxy(17,23);printf("Press Enter to go to MAIN MENU .....");
getch();
}
getche();
}
///////////////////////////////////// update record //////////////////////
void edit()
8/14/2019 Inventry Management in c
49/52
PAGE:49
C PROGRAMMING{
int j,n,i,a;
float b;
char tar[30],ch;
int count=0;
ch='y';
while(ch=='y')
{
ptr = fopen("shop.dat","rb");
clrscr();
design();
gotoxy(15,9);
printf("\xDB\xDB ENTER ID OF THE PRODUCT TO BE SOLD:");
scanf("%s",&tar);
j=0;
while((fread(&temp,sizeof(temp),1,ptr))==1)
{
if((strcmp(temp.id,tar)0))
{
x[j] = temp;
j++;
}
else
{
design();
8/14/2019 Inventry Management in c
50/52
PAGE:50
C PROGRAMMINGgotoxy(8,7);
printf("\xDB\xDB Description = %s",temp.desc);
gotoxy(8,9);
printf("\xDB\xDB Quantity in stock = %d",temp.quantity);
gotoxy(8,11);
printf("\xDB\xDB Sales price = %.2f",temp.sale);
gotoxy(8,13);
printf("\xDB\xDB Quantity want to sale : ");
scanf("%d",&a);
x[j]=temp;
x[j].quantity=(x[j].quantity-a);
x[j].total=(x[j].quantity*temp.sale);
x[j].cost=(x[j].quantity*temp.unit);
x[j].bye=(x[j].sale*a);
b=x[j].bye;x[j].qty=a;
j++;
count++;
}
}
if (count==0)
{
clrscr();
design();
gotoxy(33,10);
8/14/2019 Inventry Management in c
51/52
PAGE:51
C PROGRAMMINGprintf("\a\xDB\xDB\xB2 Not in stock");
getch();
return;
}
fclose(ptr);
n = j;
clrscr();
ptr=fopen("shop.dat","wb");
for(i=0; i
8/14/2019 Inventry Management in c
52/52
PAGE:52
C PROGRAMMING{
union REGS in, out;
in.x.ax = 0x1;
int86(0x33, &in, &out);
}
References
E Balagurusamy
Ashoke N Kamthane
www.planet-source-code.com/
www.codeproject.com/