برامج متكامله بلغة c++ - مشروع تسويق متكامل بلغة c++

مشروع تسويق متكامل بلغة c++

مهام المشروع:

1- ادارة المخزن 

- ادخال سلع جديده
- بحث عن سلعة معينه
- تعديل سلعه معين
- حذف سعله معينة
- طباعه تقرير لكافة السلع

2- بيع سلعه او منتج معين

حفظ كافة السجلات الى ملف خارجي  dat.


كود المشروع

#include <iostream>
#include <windows.h>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <conio.h>
#include <ctime>
#include <dos.h>
#include <iomanip>
using namespace std;
COORD coord = {0, 0};
void gotoxy(int x, int y)
{
 COORD coord;
 coord.X = x;
 coord.Y = y;
 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
class product
{
int pno;
char name[50];
float price,qty,tax,quant;
public:
void create_product()
{

cout<<"\nPlease Enter The Product No: ";
cin>>pno;
cout<<"\n\nPlease Enter The Name of The Product: ";
cin>>name;
cout<<"\nPlease Enter The Price of The Product: ";
cin>>price;
cout<<"\nPlease Enter The Quantity:  ";
cin>>quant;
}
void show_product()
{

cout<<"\t\t"<<pno<<" \t"<<name<<"\t"<<price<<"\t"
         <<quant<<"\n";

}
int retpno()
{return pno;}
float retprice()
{return price;}
char* retname()
{return name;}
int retquant()
{return quant;}
}; 
//class ends 

//***************************************************************
// global declaration for stream object, object
//****************************************************************
fstream fp;
product pr;
//***************************************************************
// function to write in file
//****************************************************************
void write_product()
{
fp.open("Shop.dat",ios::out|ios::app);
pr.create_product();
fp.write((char*)&pr,sizeof(product));
fp.close();
cout<<"\n\nThe Product Has Been Created ";
getch();
}
//***************************************************************
// function to read all records from file
//****************************************************************
void display_all()
{
system("cls");
cout<<"\n\n\n\t\tDISPLAY ALL RECORD !!!\n\n";
cout<<"\n\t\tID"<<" \t"<<"Name"<<"\t"<<"Price"<<"\t"
         <<"quantity"<<"\n";
cout<<"\t\t----------------------------------------\n\n";
fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
pr.show_product();
cout<<"\n\n\t\t====================================\n";
getch();
}
fp.close();
getch();
}
//***************************************************************
// function to read specific record from file
//****************************************************************
void display_sp(int n)
{
int flag=0;
fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
if(pr.retpno()==n)
{
system("cls");
pr.show_product();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nrecord not exist";
getch();
}


//***************************************************************
// function to place order and generating bill for Products
//****************************************************************
void place_order(){

int pno,quan,c=0,discount=0;
double amt,damt,total=0;
int flag=0;
char ch='Y';

cout<<"\n\t\t\t============================";
cout<<"\n\t\t\t     PLACE YOUR ORDER";
cout<<"\n\t\t\t============================\n";

cout<<"\n\nEnter The Product No. Of The Product : ";
cin>>pno;
cout<<"\nQuantity in number : ";
cin>>quan;

cout<<"\Enter The discount : ";
cin>>discount;
//c++;

cout<<"\n\nThank You For Placing The Order";getch();system("cls");
cout<<"\n\n\t  ************************INVOICE************************\n\n";

fp.open("Shop.dat",ios::in);
while(fp.read((char*)&pr,sizeof(product)))
{
if(pr.retpno()==pno)
{
//system("cls");
pr.show_product();
flag=1;

amt=pr.retprice()*quan;
damt=amt-(amt*discount/100);
cout<<"\nID\tPr Name\tQuantity\tPrice \tAmount \tThe final price after discount\n";

cout<<"\n\n"<<pno<<"\t"<<pr.retname()
<<"\t"<<quan<<"\t\t"<<pr.retprice()<<"\t"<<amt<<"\t\t"<<damt<<"\n";
total+=damt;

}

}
cout<<"\n\t\tTOTLE:"<<total<<"\n\n";



fp.close();
if(flag==0)
cout<<"\n\nrecord not exist";
getch();
}
//***************************************************************
// function to modify record of file
//****************************************************************
void modify_product()
{
int no,found=0;
system("cls");
cout<<"\n\n\tTo Modify ";
cout<<"\n\n\tPlease Enter The Product No. of The Product";
cin>>no;
fp.open("Shop.dat",ios::in|ios::out);
while(fp.read((char*)&pr,sizeof(product)) && found==0)
{
if(pr.retpno()==no)
{
pr.show_product();
cout<<"\nPlease Enter The New Details of Product"<<endl;
pr.create_product();
int pos=-1*sizeof(pr);
fp.seekp(pos,ios::cur);
fp.write((char*)&pr,sizeof(product));
cout<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}
//***************************************************************
// function to delete record of file
//****************************************************************
void delete_product()
{
int no;
system("cls");
cout<<"\n\n\n\tDelete Record";
cout<<"\n\nPlease Enter The product no. of The Product You Want To Delete";
cin>>no;
fp.open("Shop.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&pr,sizeof(product)))
{
if(pr.retpno()!=no)
{
fp2.write((char*)&pr,sizeof(product));
}
}
fp2.close();
fp.close();
remove("Shop.dat");
rename("Temp.dat","Shop.dat");
cout<<"\n\n\tRecord Deleted ..";
getch();
}
//***************************************************************
// function to display all products price list
//****************************************************************
void menu()
{
system("cls");
fp.open("Shop.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN\n\n\n Go To Admin Menu to create File";
cout<<"\n\n\n Program is closing ....";
getch();
exit(0);
}
cout<<"\n\n\t\tProduct MENU\n\n";
cout<<"====================================================\n";
cout<<"P.NO.\t\tNAME\t\tPRICE\t   Quantity\n";
cout<<"====================================================\n";
while(fp.read((char*)&pr,sizeof(product)))
{
cout<<pr.retpno()<<"\t\t"<<pr.retname()<<"\t\t"<<pr.retprice()<<"\t\t"<<pr.retquant()<<"\n\n";
}
fp.close();
}

//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************
void intro()
{
system("cls");
gotoxy(31,11);
cout<<"SUPER MARKET";
gotoxy(35,14);
cout<<"BILLING";
gotoxy(35,17);
cout<<"PROJECT";
cout<<"\n\nMADE BY : ODAI DAMMAG";

getch();
}

//***************************************************************
// ADMINSTRATOR MENU FUNCTION
//****************************************************************
void admin_menu()
{
system("cls");
int ch2;
cout<<"\n\n\n\tADMIN MENU";
cout<<"\n\n\t1.CREATE PRODUCT";
cout<<"\n\n\t2.DISPLAY ALL PRODUCTS";
cout<<"\n\n\t3.QUERY ";
cout<<"\n\n\t4.MODIFY PRODUCT";
cout<<"\n\n\t5.DELETE PRODUCT";
cout<<"\n\n\t6.VIEW PRODUCT MENU";
cout<<"\n\n\t7.BACK TO MAIN MENU";
cout<<"\n\n\tPlease Enter Your Choice (1-7) ";
//ch2=getche();
cin>>ch2;
switch(ch2)
{
case 1: system("cls");
write_product();
break;
case 2: 
 
display_all();
break;
case 3:
int num;
system("cls");
cout<<"\n\n\tPlease Enter The Product No. ";
cin>>num;
display_sp(num);
break;
case 4: modify_product();break;
case 5: delete_product();break;
case 6: menu();
getch();break;
case 7: break;
default:cout<<"\a";admin_menu();
}
}
//***************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************
void main()
{
char ch;
intro();
do
{
system("cls");
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. CUSTOMER";
cout<<"\n\n\t02. ADMINISTRATOR";
cout<<"\n\n\t03. EXIT";
cout<<"\n\n\tPlease Select Your Option (1-3) ";
//ch=getche();
cin>>ch;
switch(ch)
{
case '1': system("cls");
place_order();
getch();
break;
case '2': admin_menu();
break;
case '3':exit(0);
default :cout<<"\a";
}
}while(ch!='3');
}
//***************************************************************
// END OF PROJECT
//***************************************************************

اتمنى ان تستفيدوا من هذا المشروع
اخوكم عدي دماج,,,

Share this

مواضيع ذات صلة

Previous
Next Post »

هناك تعليق واحد:

Unknown يقول...

ليه بيطلع لي غلط في void main() ???

إرسال تعليق