project on c-programming

40
Acknowledgement Any attempt at any level cannot be satisfactorily completed without the support and guidance of learned people. We would like to express our immense gratitude to all KEC teachers on computer programming for their constant support and motivation that has encouraged us to come up with this project. We are also thankful to all our colleagues of electronics section A who have rendered their whole hearted support at all times for the successful completion of this project.

Upload: abiral-baniya

Post on 02-Dec-2014

398 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Project on C-programming

Acknowledgement

Any attempt at any level cannot be satisfactorily completed without the support and guidance of learned people. We would like to express our immense gratitude to all KEC teachers on computer programming for their constant support and motivation that has encouraged us to come up with this project.

We are also thankful to all our colleagues of electronics section A who have rendered their whole hearted support at all times for the successful completion of this project.

Page 2: Project on C-programming

Abstract

The project as the name suggests is based on the departmental store management system. A departmental store consist commodities of daily human use, so they need to be managed in various ways. This project focuses on the billing management of a departmental store and management from the manager’s desk. When a customer buys some commodities he/she can have instant bill by using this program.

For this purpose we started our project from the basic steps of programming. We constructed algorithms and made plans for the program. For the coding purpose C-programming language was used. So for the project our main tool was the C-programming language.

The result we got from the completion of the project was a well and efficient program for the billing management in a departmental store. However there are some limitations, overall the project is successful for what it aims to fulfill.

Page 3: Project on C-programming

Table of contents

Title Page Number

Objectives 1 Introduction 2 Algorithm 3 Requirements 11 Project discussion 12 Code 14 Features of project 28 Limitations 29 Conclusion 30 References 31

Page 4: Project on C-programming

Objectives

The main objectives of this project are listed as follows:

Proper management of selling items in departmental store. Can be useful for both manager and cashier. Good security of information for which password facilities are provided. Maximum providence of modification and search options. User friendly messages in the way for easy application of program.

Page 5: Project on C-programming

Introduction

The project is based on the management and billing process in departmental store. This program can be simply used by a departmental store manager and cashier. The program mainly focuses on manipulation of various functions by a cashier and manager on the basis of goods selected by the costumer. The manager can add goods, change the rates, view the total sales of the day etc. On the other hand a cashier can work out with bills of the goods as per customers’ choice.

For the coding process the ANSI Standard C Programming Language is used. The various efficient aspects such as functions, arrays, structures, file operations etc. are used.

Page 6: Project on C-programming

AlgorithmsAlgorithm for main():Step 1: Start.Step 3: Display “Welcome to Departmental Store Management System”.Step 4: Call function mainmenu().Step 5: Stop.

Algorithm for mainmenu():Step 1: Start.Step 2: Display “Main Menu".Step 3: Display “Enter the choices: (L) to login, (C) to create Manager/Cashier, (E) to exit".Step 4: Input choice1.Step 5:

5.1: if choice1=76 or choice1=108Call function Verification().

elseif choice1=67 or choice1=99

Display “Enter (M) to create Manager ID.")Display "Enter (C) to create Cashier ID."Display "Enter (R) to return to main menu:"

5.2: Input choice2.5.3: if choice2=77 or choice2=109

Call function CreateManager().elseif choice2=67 or choice2=99

Call function CreateCashier().elseif choice2=82 or choice2=114

Call function mainmenu().else

Display "Invalid Selection! Enter again:"Goto step 5.2.

Step 6: if choice1=69 or choice 1=101exit.

elseDisplay "Invalid Selection! Enter again:"Goto step 4.

Step 7: Stop.

Algorithm for CreateManager():Step 1: Start.Step 2: Declare file pointer *f1.Step 3: Declare variables master, key, name, p, pas, i.Step 4: Assign “createme” to master.Step 5: Display “Enter the master password:"Step 6: Initialize i=0.Step 7: Input pas.

7.1: if (pas !=‘\n’)

Page 7: Project on C-programming

Input pas.7.2: if (pas=13)

Goto step 10.if(pas !=‘\b’)

Assign pass to key[i],Display "\b*".

elseif (pas='\b')

Display " ",Display "\b",i=i-2.

Step 8: i=i+1.Step 9: Goto step 7.1.Step 10: Assign '\0' to key[i].Step 11: if master and key are equal

11.1: Open file “authorize1.txt” in “ab+” mode and assign to f1.if f1=NULL

Open file “authorize1.txt” in “wb+” mode and assign to f1.if f1=NULL

Display "Cannot open the file".11.2: Display "Enter the user name:"11.3: Input b.admin_name.11.4: Display "Enter the password:"11.5: Initialize i=0.11.6: Input p.11.7: if (pas !=‘\n’)

Input p.11.8: if p=13

goto step 19.if (p != ‘\b’)

Assign p to b.admin_password[i],Display "\b*".

elseif p='\b'Display " ",

Display "\b",i=i-2.11.9: i=i+1.11.10: Goto step 11.6.11.11: Assign '\0' to b.admin_password[i].11.12: Write structure b to f1.11.13: Close file f1.11.13: Display "Created Successfully!"11.14: Goto step 13.

Step 12: Display "Invalid password! You can't create a Manager's ID."Step 13: Stop.

Algorithm for Verification():

Page 8: Project on C-programming

Step 1: Start.Step 2: Declare file pointer *f1 and *f2.Step 3: Declare variables name1[50], password1[50], name2[50], password2[50], p1, p2, choice3,

choice4, flag1, len, i, j.Step 4: Assign flag1=0.Step 5: Display "To login as manager press (M)."

Display "To login as cashier press (C)"Display "To return to main menu press (R):"

Step 6: Input choice3.Step 7: if (choice3=‘M’) or (choice3=‘m’)

7.1: Open file "authorize1.txt" in "rb+" mode and assign to f1.7.2: Display "Enter the user name:"7.3: Input name1.7.4: Read file f1.7.5: if (name1=b.admin_name)

if (flag1=0)Display “Enter the password:"

i=0.Goto step 7.6.

elseGoto step 7.11.

7.6: if (p1 = '\n')if (p1='\b')Display (" "),

Print ("\b"),i=i-2.

elseInput p1.if (p1=13)

Goto step 7.9.if (p1!='\b')password1[i]=p1,

Print "\b*".

7.7: i=i+1;7.8: Goto step 7.6.7.9: password1[i]='\0'.

7.10: if (password1 = b.admin_password)flag1=1,Display "Welcome!”,Call function ManagerMenu(). else

Display "Invalid Password!"7.11: Display "User name not found."

Goto step 7.2.7.12: close file f1.

Step 8: if (choice3=‘C’) or (choice3=‘c’)8.1: Open file "authorize2.txt" in "rb+" mode and assign to f2.

Page 9: Project on C-programming

8.2: Display "Enter the user name:"8.3: Input name2.8.4: Read file f12.8.5: if (name2=b.user_name)

if (flag1=0)Display “Enter the password:"

i=0.Goto step 8.6.

elseGoto step 8.11.

8.6: if (p2 != '\n')Input p2.if (p2=13)

Goto step 7.8.if (p2!='\b')password2[i]=p2,

Print "\b*".elseif (p2='\b')Display (" "),

Print ("\b"),i=i-2.

8.7: i=i+1;8.8: Goto step 8.6.8.9: password2[i]='\0'.

8.10: if (password2 = b.user_passwordflag1=1,Display “Welcome!”,Call function CashierMenu(). else

Display “Invalid Password!”

8.11: Display “User name not found.”Goto step 8.2.

8.12: close file f2.Step 9: if (choice3=‘R’) or (choice3=‘r’)

Call Function mainmenu().else

Display “Invalid Selection! Enter again:”Goto step 4.

Step 10: Stop.

Algorithm for GoodsEntry():Step 1: Start.Step 2: Declare file pointer *f.Step 3: Declare variable ques.Step 4: Open file “goods.txt” in append mode and assign to pointer f.Step 5: Display “Enter the item code to be added:”

Page 10: Project on C-programming

Step 6: Input a.itemcode.Step 7: Display “Enter the item name:”Step 8: Input a.itemname.Step 9: Display “Enter the rate for unit quantity:”Step 10: Input a.rate.Step 11: Write structure a in f.Step 12: Display “Enter the 'esc' key to exit or any other key to continue:”Step 13: Input ques.Step 14: if (ques=27)

Goto step 15.else

Goto step 5.Step 15: Close file f.Step 16: Call function ManagerMenu().Step 17: Stop.

Algorithm for GoodsListDisplay():Step 1: Start.Step 2: Declare file pointer *f.Step 3: Open file “goods.txt” in read mode and assign it to f.Step 4: Display “Item code Item name Cost”.Step 5: Display “----------------------------------------------“.Step 6: Print a.itemcode, a.itemname, a.rate.Step 7: if (f=EOF)

Goto Step 8.else

Goto Step 6.Step 8: Close file f.Step 9: Call function ManagerMenu().

Algorithm for EditGoods():Step 1: Start.Step 2: Declare file pointer *f.Step 3: Declare variable itemcode[50], size.Step 4: Open file “goods.txt” in read mode and assign to file pointer f.Step 5: Display “Enter the item code of the product:”Step 6: Input itemcode.Step 7: Read f.Step 8: if (f=EOF)

Goto Step 11.elseif (a.itemcode=itemcode)

Display “Enter the new item code:”Input a.itemcode,

Display “Enter the new item name:”Input a.itemname,

Display “Enter the rate for unit quantity:”Input a.itemname.

Page 11: Project on C-programming

Step 9: fseek(f,-size,SEEK_CUR)Step 10: Write structure a.Step 11: Close f.Step 12: Call function ManagerMenu().Step 13: Stop.

Algorithm for DeleteGoods():Step 1: Start.Step 2: Declare file pointer *f, *temp.Step 3: Declare variable itemcode[50], size.Step 4: Open file “goods.txt” in read mode and assign to file pointer f.Step 5: Open file “tempgoods.txt” in write mode and assign to file pointer temp.Step 6: Display “Enter the item code of the product to be deleted:”Step 7: Input itemcode.Step 8: Read f.

if (f=EOF)Goto Step 9.

elseif (itemcode=a.itemcode)

Goto Step 8.else

Write a in temp.Step 9: Remove file “goods.txt”.Step 10: Rename “tempgoods.txt” to “goods.txt”.Step 11: Close f.Step 12: Close temp.Step 13: Call function ManagerMenu().Step 14: Stop.

Algorithm for Billing():Step 1: Start.Step 2: Declare structure goods b[50] and variables itemcode[50], i, j, sum, quantity[200], cost[200],

tender, change.Step 3: Declare file pointer *f, *f1.Step 4: Open file “goods.txt” in read mode and assign to f.Step 5: Open file “keeprecords.dat” in append mode and assign to f1.Step 6: Initialize i=0.Step 7: Display “Enter the item codes and enter any key when done.”Step 8: Display “Enter the item codes:”Step 9: Input itemcode.Step 10: if (strlen(itemcode)=6)

Goto Step 11.else

Goto Step 16.Step 11: Read f. Step 12: if (a.itemcode=itemcode)

Print a.itemname, a.rate,b[i].itemcode=a.itemcode,

Page 12: Project on C-programming

b[i].itemname=a.itemname,b[i].rate=a.rate,Display "Enter the quantity:"

Input quantity[i],cost[i]=quantity[i]*b[i].rate,

sum=sum+cost[i],c.itemcode=b[i].itemcode,

c.itemname=b[i].itemname,c.rate=b[i].rate,c.quantity=quantity[i],c.cost=cost[i].

Step 13: Write c in f1.Step 14: i++,Step 15: Goto Step 8.Step 16: Close f and f1.Step 17: Display “Item code Item name Cost Qty Amount”.Step 18: Display “-------------------------------------------------”.Step 19: Initialize j=0.Step 20: if (j<i)

Print b[j].itemcode, b[j].itemname, b[j].rate, quantity[j], cost[j].j=j+1,Goto step 18.

Step 21: Print sum.Step 22: Display “Tender:”Step 23: Input tender.Step 24: change=tender-sum.Step 25: Print change.Step 26: Print CashierName.Step 27: Call function CashierMenu().

Algorithm for TotalSalesDisplay():Step 1: Start.Step 2: Declare file pointer *f4.Step 3: Open file “keeprecords.dat” in read mode and assign to f4.Step 4: Display “Item code Item name Cost Quantity Amount”.Step 5: Display “------------------------------------------------------------------”.Step 6: Read f4.Step 7: if (f4=EOF)

Goto step 8.else

Print c.itemcode, c.itemname.grandtotal=grandtotal+c.costPrint c.rate, c.quantity, c.cost.Goto Step 7.

Step 8: Print grandtotal. Step 9: Close f4.Step 10: Call Function ManagerMenu().

Page 13: Project on C-programming

Algorithm for ManagerMenu():Step 1: Start.Step 2: Declare variable choice4.Step 3: Display “Enter (A) to add to good list.”

Display “Enter (E) to edit the good list.”Display “Enter (D) to display list of goods.”Display “Enter (S) to view the total sales.”Display “Press (space bar) to delete to good list.”Display “Enter (R) to return to Main Menu:”

Step 4: Input choice4.Step 5: if (choice4=‘A’) or (choice4=‘a’)

Call function GoodsEntry().elseif (choice4=‘E’) or (choice4=‘e’)

Call function EditGoods().elseif (choice4=‘D’) or (choice4=‘d’)

Call function GoodsListDisplay().elseif (choice4=‘ ’) or (choice4=‘ ’)

Call function DeleteGoods().elseif (choice4=‘S’) or (choice4=‘s’)

Call function TotalSalesDisplay().elseif (choice4=‘R’) or (choice4=‘r’)

Call function mainmenu().else

Display “Invalid Selection! Enter again:”Goto Step 4.

Step 6: Stop.

Algorithm for CashierMenu():Step 1: Start.Step 2: Declare variable ch.Step 3: Display “Billing is ready!”Step 4: Display “Press (E) to exit or any other key to continue billing:”Step 5: Input ch.Step 6: if (ch=‘E’) or (ch=‘e’)

exit.else

Call function Billing().Step 7: Stop.

Page 14: Project on C-programming

Requirements

The requirements for the program to run or for the code to be in effect are basic and can be found on any simple computer. However some of the essential hardware and software requirements are described as follows:

Hardware:

The hardware required for the program to run is same as the hardware that can be found on simple personal computer (Desktop, Laptop, etc.).So there is no such special hardware requirement for the implementation of this project.

Software:

As the C-programming language is used for the coding purpose, the main software required is also the same. The installation of this software is not much complicated and it does not occupy much space. The system requirement for the program to run is also basic and not hard to be found.

Platform:

C-program supports platform such as windows 98, Xp, 2000, etc. However it may not support some of the latest operating systems.

Page 15: Project on C-programming

Project Discussion

As we know the project is based on the departmental management system and focuses on the billing system. The functions used in the program or the function of the program also intends in parallel direction. The main components of the program are to start as a manager or cashier and verification, goods entry and display, bill display, total sales display, etc. These components are described as follows along with their working process:

Start as a manager or cashier and verification:

The program supports two modes namely manager mode and cashier mode. At the start of the program it is asked to login as existing user or new user. The new user can be in manager mode or in cashier mode. For the new user to be in manager mode should enter a master password as manager have got some secret information which cannot be disclosed among other members. Each member can also have their own passwords for excess. When a user enters correct username and password than the “welcome” message is displayed, otherwise the user is again asked to enter the username and password correctly.

Manager mode:

Manager is the main person who manages the purchase and sales of goods in a departmental store. So, a manager mode should have various aspects such as adding to good list, editing, and display of good list, to view the total sales of a day and to delete a good. These all aspects are included in the program under the manager mode.

For the entry of new goods a manager should select the option “add to good list”. Then he is asked the item code of the good that is to be added. He is also requested to enter the name of the good and the rate of the unit quantity. If a manager wants to view the list of all of his goods then he can select the option “goods list display”. This option displays all the available goods in the following format:

Item code Item name Cost

…………………………………………………………………………………………………………………………………………

A manager can edit the existing good list. For this he should select the option “edit the good list”. In this option he can give new item code, name and rate for the existing item. The code of the item that is to be edited is asked and the new code, name and rate are assigned in place of the existing good. A good manager should keep all the record of sales of a day which can help in many ways for the future of the departmental store. For this purpose he can select the option “view the total sales”. This option displays the total goods sold per day, their code, cost, quantity and total amount. The total sale of a day is displayed in following format:

Item code Item name Cost Quantity Amount

……………………………………………………………………………………………………………………………………………….

Page 16: Project on C-programming

Lastly, a manager can delete or stop the purchase or sales of the goods in the department as per the requirement. For this he can select the option “delete the good”. When this option is selected then the code of the item to be deleted is asked from him. If code of some item is entered than the respective item is deleted from the list.

Cashier Mode:

A cashier is a person who takes orders from customers as well as gives and receives money. In case of a departmental store a cashier calculates the total amount of goods a customer wants to purchase and print out the bill, also a cashier takes the amount from the customer.

A cashier input the code of the items which a customer wants to purchase. Then the item codes, names of the items, cost, quantity and total amount is calculated. Lastly the bill is processed. The processed bill is displayed as in total sales display format of the manager mode. However the change to be returned to the customer and the name of the cashier is also displayed at the end of the bill.

Thus these are the main components of our program along with their functions and their working process.

Page 17: Project on C-programming

Source Code

/*This program helps managing a departmental store by helping to define goods, keep its records, make bills, keep records of the sales*/

#include <stdio.h>#include <conio.h>#include <string.h>#include<dos.h>voidmainmenu();voidCreateManager();voidCreateCashier();void Verification();voidManagerMenu();voidCashierMenu();voidGoodsEntry();voidGoodsListDisplay();voidEditGoods();voidDeleteGoods();void Billing();voidTotalSalesDisplay();struct goods{

charitemcode[50];charitemname[50];int rate;

}a;struct authorize{

charadmin_name[50];charadmin_password[50];charuser_name[50];charuser_password[50];

}b;struct goods2{

charitemcode[50];charitemname[50];int rate;int quantity;int cost;

}c;charCashierName[50];intgrandtotal=0;char choice1,choice2;void main()

Page 18: Project on C-programming

{longinti,j;printf ("Welcome to DEPARTMENTAL STORE MANAGEMENT SYSTEM\n\n");printf ("\nLoading");for (i=0;i<3;i++){

for (j=0;j<=200000000;j++);printf (".");

}mainmenu();

}

voidmainmenu(){

printf ("\nMAIN MENU");printf ("\nEnter the choices:\n(L) to login.\n(C) to create Manager/Cashier.\n(E) to exit:");askchoice2:choice1=getche();switch (choice1){

case 76:case 108:

Verification();break;case 67:case 99:

printf ("\nEnter (M) to create Manager ID.\n");printf ("Enter (C) to create Cashier ID.\n");printf ("Enter (R) to return to main menu:\n");askchoice1:choice2=getche();switch(choice2){case 77:case 109:CreateManager();break;case 67:case 99:CreateCashier();break;case 82:case 114:mainmenu();break;

default:{

printf ("\nInvalid Selection!\nEnter again:\n");goto askchoice1;}}break;

case 69:

Page 19: Project on C-programming

case 101:exit(1);

default:{

printf ("\nInvalid Selection!\nEnter again:");goto askchoice2;

}}

}

voidCreateManager(){

FILE *f1;char master[]="createme",key[10],name,p,pas;int i;printf ("\nEnter the master password:");i=0;while (pas!='\n')

{pas=getche();

if (pas==13)break;if (pas!='\b')

{key[i]=pas;printf("\b*");

}else if (pas=='\b') {

printf (" ");printf ("\b");i=i-2;

} i=i+1;

}printf ("\n");key[i]='\0';if (strcmp(master,key)==0) {

if((f1=fopen("authorize1.dat","ab+"))==NULL){

if ((f1=fopen("authorize1.dat","wb+"))==NULL){

printf ("cannot open the file");getch();

}}printf ("\nEnter the user name:");

Page 20: Project on C-programming

gets(b.admin_name);printf ("\nEnter the password:");i=0;while (p!='\n')

{p=getche();if (p==13)

break;if (p!='\b'){b.admin_password[i]=p;printf("\b*");}else if (p=='\b'){printf (" ");printf ("\b");i=i-2;}i=i+1;

}printf ("\n");b.admin_password[i]='\0';fwrite(&b,sizeof(b),1,f1);

fflush(stdin);fclose(f1);printf ("Created Successfully!");

}elseprintf ("Invalid password! You can't create a Manager's ID.");getch();mainmenu();

}

voidCreateCashier(){

FILE *f2;charname,p;int i;if((f2=fopen("authorize2.dat","ab+"))==NULL){

if ((f2=fopen("authorize2.dat","wb+"))==NULL){

printf ("Cannot open.");}

}printf ("\nEnter the cashier's name:");gets(b.user_name);

Page 21: Project on C-programming

printf ("\nEnter the password:");i=0;while (p!='\n')

{p=getche();

if (p==13)break;

if (p!='\b') {

b.user_password[i]=p;printf("\b*");

}else if (p=='\b') {

printf (" ");printf ("\b");i=i-2;

} i=i+1;

}printf ("\n");

b.user_password[i]='\0';fwrite(&b,sizeof(b),1,f2);

fflush(stdin);fclose(f2);printf ("Created Successfully!");mainmenu();

}

void Verification(){

FILE *f1;FILE *f2;int i,flag1=0,len,j;char name1[50],password1[50],name2[50],password2[50],p1,p2;char choice3,choice4;printf ("\nTo login as manager press (M).");printf ("\nTo login as cashier press (C)");printf ("\nTo return to main menu press (R):\n");la1:choice3=getche();switch (choice3){

case 77:case 109:

if((f1=fopen("authorize1.dat","rb+"))==NULL)printf ("Cannot open");askname:

Page 22: Project on C-programming

printf ("\nEnter the user name:");gets(name1);while(fread(&b,sizeof(b),1,f1)==1){

if (strcmp(name1,b.admin_name)==0){ while (flag1==0)

{printf ("\nEnter the password:");

i=0;while (p1!='\n'){

p1=getche();if (p1==13)break;if (p1!='\b'){password1[i]=p1;printf("\b*");}else if (p1=='\b'){printf (" ");printf ("\b");i=i-2;}i=i+1;

}printf ("\n");password1[i]='\0';

if (strcmp(password1,b.admin_password)==0){

flag1=1;printf ("Welcome!");

ManagerMenu();

}else{

printf ("\nInvalid Password!");for (j=0;j<45;j++)

password1[j]='\0';getch();

}}break;

}else

Page 23: Project on C-programming

{printf ("\nUser name not found.\n");

getch();rewind(f1);gotoaskname;}

fclose(f1);}break;case 99:case 67:

f2=fopen("authorize2.dat","rb+");askname1:printf ("\nEnter the user name:");gets(name2);while(fread(&b,sizeof(b),1,f2)==1){

if (strcmp(name2,b.user_name)==0){

while (flag1==0){

strcpy(CashierName,name2);printf ("\nEnter the password:");i=0;

while (p2!='\n'){

p2=getche();if (p2==13)break;if (p2!='\b'){password2[i]=p2;printf("\b*");}else if (p2=='\b'){printf (" ");printf ("\b");i=i-2;}i=i+1;

}printf ("\n");password2[i]='\0';if (strcmp(password2,b.user_password)==0){

flag1=1;printf ("Welcome!");

Page 24: Project on C-programming

CashierMenu();break;

}else{

printf ("Invalid Password!");for (j=0;j<45;j++)password1[j]='\0';

}}

break;}

else{printf ("User name not found");getch();rewind(f2);goto askname1;

}}

fclose(f2); break;

case 114:case 82:

mainmenu();break;default:

printf ("\nInvalid Selection!\nEnter again:\n");goto la1;

}}

voidCashierMenu(){

longinti,j;charch;printf ("\nLoading");for (i=0;i<3;i++){

for (j=0;j<=200000000;j++);printf (".");

}printf ("\nBilling is ready!");printf ("\nPress (E) to exit.\nOR\nAny other key to continue billing:\n");ch=getche();switch (ch){

case 69:case 101:exit(1);

Page 25: Project on C-programming

default:Billing();

}}

voidManagerMenu(){

char choice4;longinti,j;printf ("\nLoading");for (i=0;i<3;i++){

for (j=0;j<=200000000;j++);printf (".");

}printf ("\nEnter (A) to add to good list.");printf ("\nEnter (E) to edit the good list.");printf ("\nEnter (D) to display list of goods.");printf ("\nEnter (S) to view the total sales.");printf ("\nPress (space bar) to delete to good list.");printf ("\nEnter (R) to return to Main Menu:\n");la2:

choice4=getche();switch (choice4){case 65:case 97:GoodsEntry();break;

case 69:case 101:EditGoods();break;case 68:case 100:GoodsListDisplay();break;case 32:DeleteGoods();break;case 115:case 83:TotalSalesDisplay();break;case 82:case 114:mainmenu();break;default:printf("\nInvalid Selection!\nEnter again:\n");goto la2;}

}

Page 26: Project on C-programming

voidGoodsEntry(){

FILE *f;charques; if ((f=fopen("goods.txt","ab+"))==NULL){

if ((f=fopen("goods.txt","wb+"))==NULL){

printf ("\nCannot open the file\n");getch();

}}while(1){

printf ("\nEnter the item code to be added:");gets (a.itemcode);printf ("\nEnter the item name:");gets (a.itemname);printf ("\nEnter the rate for unit quantity:");scanf ("%d",&a.rate);fwrite(&a,sizeof(a),1,f);fflush(stdin);printf ("\nEnter the 'esc' key to exit or any other key to continue:");ques=getche();if(ques==27)

break;}fclose(f);ManagerMenu();

}

voidGoodsListDisplay(){

FILE *f;inti,j;printf ("\nLoading");for (i=0;i<4;i++){

for (j=0;j<=100000000;j++);printf (".");

}printf ("\b\b\b \b\b\b");for (i=0;i<3;i++){

for (j=0;j<=100000000;j++);printf (".");

}printf ("\b\b\b");

Page 27: Project on C-programming

if ((f=fopen("goods.txt","rb"))!=NULL){

printf ("\n Item code Item name Cost(Rs.)\n");printf ("-------------------------------------------------------\n");do{

printf("%s",a.itemcode);printf("\t\t");printf("%s",a.itemname);if ((strlen(a.itemname)>0)&& (strlen(a.itemname)<=7))printf("\t\t");

if ((strlen(a.itemname)>7)&& (strlen(a.itemname)<13))printf ("\t ");if ((strlen(a.itemname)>=13) && (strlen(a.itemname)<16))printf ("\t");printf ("\t\t%d\n",a.rate);

}while (fread(&a,sizeof(a),1,f)==1);fclose(f);getch();

}ManagerMenu();

} voidEditGoods(){

FILE *f;charitemcode[50];int size=sizeof(a);if ((f=fopen("goods.txt","rb+"))!=NULL){

printf ("\nEnter the item code of the product:");gets(itemcode);fflush(stdin);while (fread(&a,sizeof(a),1,f)==1){

if (strcmp(a.itemcode,itemcode)==0){printf ("\nEnter the new item code:");gets (a.itemcode);printf ("\nEnter the new item name:");gets (a.itemname);printf ("\nEnter the rate for unit quantity:");scanf ("%d",&a.rate);fseek(f,-size,SEEK_CUR);fwrite(&a,sizeof(a),1,f);printf ("Done.\n");getch();break;}

Page 28: Project on C-programming

}fclose(f);

}ManagerMenu();

}

voidDeleteGoods(){

FILE *f,*temp;charitemcode[50];int size=sizeof(a);f=fopen("goods.txt","rb");temp=fopen("tempgoods.txt","wb");printf ("\nEnter the item code of the product to be deleted:");gets(itemcode);while (fread(&a,sizeof(a),1,f)==1){if (strcmp(a.itemcode,itemcode)==0)continue;elsefwrite(&a,sizeof(a),1,temp);

}rename("tempgoods.txt","goods.txt");fclose(f);fclose(temp);printf ("\nSuccessfully Deleted!");ManagerMenu();

}

void Billing(){

struct goods b[50];FILE *f;FILE *f1;charitemcode[50];int i=0,j,sum=0;int quantity[200],cost[200],tender,change;f=fopen("goods.txt","rb+");f1=fopen("keeprecords.dat","ab+");printf ("\n\nEnter the item codes and enter any key when done.");do{

printf ("\nEnter the item codes:\n");scanf("%s",&itemcode);while(fread(&a,sizeof(a),1,f)==1){

if(strcmp(a.itemcode,itemcode)==0){puts(a.itemname);printf ("Rs.%d\n",a.rate);

Page 29: Project on C-programming

strcpy (b[i].itemcode,a.itemcode);strcpy (b[i].itemname,a.itemname);b[i].rate=a.rate;printf("Enter the quantity:");scanf ("%d",&quantity[i]);cost[i]=quantity[i]*b[i].rate;sum=sum+cost[i];strcpy (c.itemcode,b[i].itemcode); strcpy (c.itemname,b[i].itemname);c.rate=b[i].rate;c.quantity=quantity[i];c.cost=cost[i];fwrite(&c,sizeof(c),1,f1); fflush(stdin);

i++;break;}

}rewind(f);

}while (strlen(itemcode)==6);fclose(f);fclose(f1);printf ("\n Item code Item name Cost\t\tQty\t\tAmount\n");printf ("------------ ----------- ---------\t\t----\t\t------\n");for (j=0;j<i;j++){

printf("%s",b[j].itemcode);printf("\t\t");printf("%s",b[j].itemname);if ((strlen(b[j].itemname)>0)&& (strlen(b[j].itemname)<=7))printf("\t\t");if ((strlen(b[j].itemname)>7)&& (strlen(b[j].itemname)<13))printf ("\t");if ((strlen(b[j].itemname)>=13) && (strlen(b[j].itemname)<16))printf ("\t");printf ("\t%d\t\t%d\t\t%d\n",b[j].rate,quantity[j],cost[j]);

}printf ("\n\t\t\tTotal:\tRs.%d",sum); printf ("\n\t\t\tTender:\tRs.");scanf ("%d",&tender);change=tender-sum;printf ("\t\t\tChange:\tRs.%d",change);printf ("\nCashier: ");puts(CashierName);getch();CashierMenu();

}

Page 30: Project on C-programming

voidTotalSalesDisplay(){

FILE *f4;longint i=0,j,k;printf ("\nLoading");for (k=0;k<3;k++){

for (j=0;j<=200000000;j++);printf (".");

}if ((f4=fopen("keeprecords.dat","r+"))!=NULL){

printf ("\n Item code Item name Cost Quantity Amount\n");printf ("-------------------------------------------------------------------------\n");do{

printf("%s",c.itemcode);printf("\t\t");printf("%s",c.itemname);grandtotal=grandtotal+c.cost;if ((strlen(c.itemname)>0)&& (strlen(c.itemname)<=7))printf("\t\t");if ((strlen(c.itemname)>7)&& (strlen(c.itemname)<13))printf ("\t");if ((strlen(c.itemname)>=13) && (strlen(c.itemname)<16))printf ("\t");printf ("\t%d\t %d\t\t%d\n",c.rate,c.quantity,c.cost);i=i+1;

}while (fread(&c,sizeof(c),1,f4)==1);

printf ("\nTotal Sales=Rs. %d.00",grandtotal); fclose(f4);getch();

}ManagerMenu();

}

Page 31: Project on C-programming

Features of Project

The features of any project are based on how it works and how it can make impact on day to day life of a human being. Departmental store carries a great value in a life of a normal man. A man needs his basic need of food, cloth which he can get it from a departmental store. As this program is focused on the proper management of a departmental store so, it carries a great scope in the society. Anyway, some of the main features of this project are described under the headings as follows:

Double mode system:

The project holds two modes and can be used by a manager and a cashier of a departmental store. A manager can manipulate the purchase and sales of the goods in the store whereas a cashier process out the bill according to the goods a customer wants to buy. So, the program is very much beneficial for the store.

Management:

The project mainly focuses on proper management of selling items in a departmental store. Various search and modification options are provided in the program. These options help in the good management of the store. A manager have got much options compared to a cashier. This makes manager mode more vulnerable. So the need of security was our prime effort.

Security:

Another feature of the program is its security. The password system is implied for each and every member who is using this program. A manager holds a master password this gives the manager mode extra security. Thus any secure program is much user friendly and holds great impact in society which is made available in our project.

User friendly messages:

Any program can be popular among the user if they are user friendly. The program uses the user friendly messages for interface with user. This helps in the easy application of the program among the user. The messages are not hard to understand and are written in simple English.

Therefore these are the main features of our project. These features are included in our program and each of these features is the jewel of our project.

Page 32: Project on C-programming

Limitations

Any project is not perfect. Every project has got some limitations. Our project also has got some limitations. These limitations may be because it is a mini project and we are also not an expert. Some of the main limitations of the project or program are listed as follows:

The display attraction of the program is poor. No interesting graphics are used as there is no use of <graphics.h> in the program.

No use of date and time function. The option of editable password is not used considering the length of the program. The program only focuses on providing options to a manager and cashier but it cannot provide

much of the options for the customer in a departmental store.Thus these are the main limitations of the projects. If these limitations can be overcome

than our program would have been a perfect one.

Page 33: Project on C-programming

Conclusion

Therefore we can conclude that the project has been successful for what it aims to perform. This program under the project can be used in a departmental store for the proper management of purchase and sales of the goods along with the billing management.

Hence although the project got some of its limitations the maximum effort was targeted for the gain of its aim i.e. departmental store management system.

Page 34: Project on C-programming

References

Various links provided by google.com. Learning C by examples, Krishna Kandel.