C++ Project on Sales Management System

Submitted by Editor

Sales Management

/*		****************************
		*  SALES MANAGEMENT SYSTEM *
		****************************
*/
#include
#include
#include
#include
#include
#include
#include
#include

struct date_rec	//	record to get date
{
short int day;
short int month;
int year;
}current_date;

struct node	//	structure to make an index of the record nos.
{
int rec_no;
node *link;
};
node *start,*ptr;

//	DECLAIRING CLASS HERE
//      this class defines data related to items

class item_list
{
private:
int item_code,qty_in_stock; //item code and quantity in stock
char item_name[30];
float item_rate;
public:
item_list()	//no argument constructor
{
item_code=0;
memset(item_name,0,30);
item_rate=0.0;
qty_in_stock=0;
}
void get_item();	//this function reads the private member of item file
int vallidate(int item_code,int qty);
//this function verifies item code correponding qty in stock
float update_on_sale(int ic1,int ic2,int ic3,int ic4,int ic5,
		     int iq1,int iq2,int iq3,int iq4,int iq5);
//this function updates the qty whenever item is purchased

void update_on_purchase(item_list temp_item);
void purchase_order();
//to generate purchase order list if stock is less than 20

node* create_list();  	//create an index of objects
void items_available();	//display the item available
}item;           	//object list

//      this class defines the data and member function related to
//	sales of an item.

class sales_list
{
private:
int cash_memo_num;
date_rec cash_memo_date;
int item_code1,i_qty1;
int item_code2,i_qty2;
int item_code3,i_qty3;
int item_code4,i_qty4;
int item_code5,i_qty5;
float total_amount;

public:
char ch;
sales_list()	//	constructor
{
item_code1=i_qty1=0;
item_code2=i_qty2=0;
item_code3=i_qty3=0;
item_code4=i_qty4=0;
item_code5=i_qty5=0;
total_amount=0.0;
}

//  this function checks for availability of an item and its quantity
int vallidate_item(int item_code,int qty);

//  this function generates record number automatically
int get_memo_no(struct date_rec current_date);
//  this function collects information to prepare cash memo
void get_chmo_info();
void show_data();	//  this function displays data

//   this function adds a record to the master file
void update_sales_file(int memo_num,int ic1,int ic2,int ic3,int ic4,int ic5,
		       int iq1,int iq2,int iq3,int iq4,int iq5,float amount);
void daily_sales_report(struct date_rec current_date);
}cash_memo;	//  object list

//  DECLARING MEMBER FUNCTIONS HERE

//  this member function reads the private members of class itemfile
void item_list::get_item()
{
gotoxy(20,5);
cout< <"ENTER THE ITEM CODE ------------>";
cin>>item_code;
gotoxy(20,6);
cout< <"ENTER THE ITEM NAME ------------>";
gets(item_name);
gotoxy(20,7);
cout< <"ENTER THE ITEM RATE ------------>";
cin>>item_rate;
gotoxy(20,8);
cout< <"ENTER THE QUANTITY ------------->";
cin>>qty_in_stock;
}

//  this member function enters a new item in itemfile, calls get_item();

void item_list::update_on_purchase(item_list temp_item)
{
fstream item_file;
//item.get_item();
item_file.open("itemfile.dat",ios::app | ios::in | ios::out);
// open file in append mode
int found=0;
item_file.seekg(0);
item_file.read((char*)&item,sizeof(item));
int n=item_file.tellg();
while(!item_file.eof())
   {
     if(item.item_code==temp_item.item_code)
	{
	   item.item_rate=temp_item.item_rate;
	   item.qty_in_stock=item.qty_in_stock+temp_item.qty_in_stock;
	   item_file.seekg(n-sizeof(item));
	   item_file.write((char*)&item,sizeof(item));
	   found=1;
	}
     item_file.read((char*)&item,sizeof(item));	// write in the file
     n=item_file.tellg();
   }
item_file.close();
if(found==0)
   {
   item_file.open("itemfile.dat",ios::app,ios::out);
   item_file.seekg(0,ios::end);
   item_file.write((char*)&temp_item,sizeof(temp_item));
   item_file.close();
   }
}

//  this member function checks for the availability of item and quantity

int item_list::vallidate(int i_code,int i_qty)
{
  item_list temp_item;
  fstream item_file;
  int ret=0;
  item_file.open("itemfile.dat",ios::in);
  item_file.seekg(0);
  item_file.read((char*)&temp_item,sizeof(temp_item));
while(!item_file.eof())
  {
    if(temp_item.item_code==i_code&&temp_item.qty_in_stock>=i_qty)
	ret=1;
    item_file.read((char*)&temp_item,sizeof(temp_item));
  }
item_file.close();
return ret;
}

float item_list::update_on_sale(int ic1,int ic2,int ic3,int ic4,int ic5,
				int iq1,int iq2,int iq3,int iq4,int iq5)
{
fstream item_file;
float amount=0;
item_file.open("itemfile.dat",ios::in);
item_file.seekg(0);//set file pointer to the begining of the file
item_file.read((char*)&item,sizeof(item));
int n=item_file.tellg();
while(!item_file.eof())
  {
    if(item.item_code==ic1)
    {
      if(item.vallidate(ic1,iq1))
      {
       gotoxy(59,9);
       cout< rec_no=item.item_code;	//save record no. in the index
	ptr->link=new node;	//get new node for the record
	ptr=ptr->link;
	item_file.read((char*)&item,sizeof(item));    //read the next record
	}
	ptr->link=NULL;		//end of the list
	item_file.close();
	return start;
	}
	void item_list::items_available()
	{
	fstream item_file;
	clrscr();
	gotoxy(20,2);
	cout< <"ITEM AVAILABLE";
	gotoxy(20,3);
	cout<<"--------------";
	gotoxy(10,5);
	cout<<"ITEM CODE";
	gotoxy(10,6);
	cout<<"---------";
	gotoxy(20,5);
	cout<<"STOCK";
	gotoxy(20,6);
	cout<<"-----";
	gotoxy(30,5);
	cout<<"ITEM NAME";
	gotoxy(30,6);
	cout<<"---------";
	gotoxy(40,5);
	cout<<"ITEM RATE";
	gotoxy(40,6);
	cout<<"---------";
	int y=7;
	item_file.open("itemfile.dat",ios::in);
	item_file.seekg(0);
	item_file.read((char*)&item,sizeof(item));
	while(!item_file.eof())
	{
	gotoxy(10,y);
	cout<link!=NULL)
	{
	int qty=0;
	sales_file.open("cashmemo.dat",ios::in);
	sales_file.seekg(0,ios::beg);
	sales_file.read((char*)&cash_memo,sizeof(cash_memo));
	while(!sales_file.eof())
	{
	if(current_date.day==cash_memo_date.day&&current_date.month==
	cash_memo_date.month&&current_date.year==cash_memo_date.year)
		{
		if(ptr->rec_no==cash_memo.item_code1)
		  qty=qty+cash_memo.i_qty1;
		if (ptr->rec_no==cash_memo.item_code2)
		  qty=qty+cash_memo.i_qty2;
		if(ptr->rec_no==cash_memo.item_code3)
		  qty=qty+cash_memo.i_qty3;
		if (ptr->rec_no==cash_memo.item_code4)
		  qty=qty+cash_memo.i_qty4;
		if(ptr->rec_no==cash_memo.item_code5)
		  qty=qty+cash_memo.i_qty5;
		}
		sales_file.read((char*)&cash_memo,sizeof(cash_memo));
		}
		sales_file.close();
		gotoxy(20,y);
		cout< rec_no;
		gotoxy(40,y);
		cout< link;
		}
		//sales_file.close();
		}


//		MAIN FUNCTION
void main()
{
char ch;
int key,main_choice,valid=0;
	do
	{
		clrscr();	//clear screen
		if (valid!=0)
		{
		gotoxy(25,11);
		cout< <"INVALID DATE";
		gotoxy(25,12);
		cout<<"PRESS ANY KEY TO TRY AGAIN";
		getch();
		clrscr();
		}
		gotoxy(22,10);
		cout<<"ENTER CURRENT DATE(dd/mm/yyyy)";
		gotoxy(25,11);
		cin>>current_date.day>>ch>>current_date.month>>
		ch>>current_date.year;
		valid=(current_date.day<0)||(current_date.day>31)
		  ||(current_date.month>12)||(current_date.month< =0)
		  ||(current_date.year<1998);	//validate date
		}while(valid !=0);

		do
		{
		clrscr();
		gotoxy(20,5);
		cout<<"ABC DEPARTMENTAL STORE";
		gotoxy(20,7);
		cout<<"----------------";
		gotoxy(20,7);
		cout<<"-----------------";
		gotoxy(22,10);
		cout<<"SUPERVISOR	..........S";
		gotoxy(22,12);
		cout<<"CASHMEMO		...........C";
		gotoxy(22,14);
		cout<<"QUIT		...........Q";
		main_choice=toupper(getch());
		switch(main_choice)
			{
			case 'S':int s_choice;
				do
				{
				clrscr();
				gotoxy(28,2);
				cout<<"---------------";
				gotoxy(28,3);
				cout<<"SUPERVISOR MODE";
				gotoxy(28,4);
				cout<<"----------------";
				gotoxy(20,6);
				cout<<"UPDATE STOCK ON PURCHASE	     .....1";
				gotoxy(20,8);
				cout<<"TODAY'S SALES REPORT	     .....2";
				gotoxy(20,10);
				cout<<"LIST OF ITEM AVAILABLE	     .....3";
				gotoxy(20,12);
				cout<<"PURCHASE ORDER LIST	     .....4";
				gotoxy(20,14);
				cout<<"EXIT SUPERVISOR MODE	     .....5";
				gotoxy(20,16);
				cout<<"ENTER YOUR CHOICE ----------------->";
				cin>>s_choice;
				switch(s_choice)
				{
				case 1:int key;
					do
					{
					item_list temp_item;
					clrscr();
					temp_item.get_item();
					temp_item.update_on_purchase(temp_item);
					gotoxy(18,24);
					cout< <"CONTINUE:C	QUIT:Q";
					key=toupper(getch());
					}
					while(key!='Q');
					break;
				case 2: clrscr();
					item.create_list();
					cash_memo.daily_sales_report(current_date);
					getch();
					break;
				case 3: item.items_available();
					getch();
					break;
				case 4: clrscr();
					item.purchase_order();
					getch();
					break;
				case 5: break;
				}
			}
		while(s_choice !=5);
		break;
	case 'C': do
		{
		int memo_num;
		memo_num=cash_memo.get_memo_no(current_date);
		clrscr();
		gotoxy(24,1);
		cout<<"------------------------------";
		gotoxy(24,2);
		cout<<"ABC DEPARTMENTAL STORE";
		gotoxy(24,3);
		cout<<"------------------------------";
		gotoxy(30,5);
		cout<<"CASHMEMO";
		gotoxy(30,6);
		cout<<"--------------------------------";
		gotoxy(10,7);
		textbackground(RED+BLINK);
		cprintf("DATE:");
		cout<>ic1;
		gotoxy(41,9);
		cin>>iq1;
		gotoxy(24,10);
		cin>>ic2;
		gotoxy(41,10);
		cin>>iq2;
		gotoxy(24,11);
		cin>>ic3;
		gotoxy(41,11);
		cin>>iq3;
		gotoxy(24,12);
		cin>>ic4;
		gotoxy(41,12);
		cin>>iq4;
		gotoxy(24,13);
		cin>>ic5;
		gotoxy(41,13);
		cin>>iq5;
		float total_amount=0;
		total_amount=
		total_amount=item.update_on_sale(ic1,ic2,ic3,ic4,ic5,
					       iq1,iq2,iq3,iq4,iq5);
		gotoxy(25,15);
		cout< 

Add Your Comment - Guidelines
You can express your opinion or reaction in the form below!

100 characters required

0 Comments:

Be the first one to comment!

You may also want to see:
QUOTE OF THE DAY
I've learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel. - Maya Angelou
March 28th, 2024 - Thursday
background

Sign in to continue