1. Login, untuk mengetahui apakah user tersebut adalah pelanggan atau admin
2. Modify Data, hanya dapat dilakukan oleh admin dan digunakan untuk mengatur (menambah atau mengubah atau menghapus) record barang-barang
3. Search, untuk para pengguna agar dapat mencari barang yang diinginkan dengan cepat
4. Sales, untuk para pelanggan melakukan penjualan
Untuk source code nya adalah seperti berikut
/*
***********************************************************
* project on *
* Departmental store management system *
***********************************************************
*/
#include<iostream.h> //for input output stream regulation
#include<conio.h> //for getch()and clreo/ clrscr
#include<fstream.h> //for file
#include<string.h> //for strcmp()
#include<stdio.h> // for input and output/ fflush()
#include<dos.h> // for delay()
#include<process.h> // for exit()
class departmental // class defined
{
private:
char gname[30];
int price,new_price,qty; // private memebers
int id,tc;
int quantity;
double total,qt,tot,stot,prof;
public:
void add_record();
void show_record(); // public members
void search_record();
void search_record_name();
void update_record();
void delete_record();
void tasks();
int check_id();
void sales();
void notification();
void report();
}; // end of class departmental
class extra // class extra defined
{
private:
int i ,j ;
public:
void music();
void mainmenu();
void blink_message(char msg[]);
void subblinkmessage(char msg[]);
void line1(int x, int y, int z);
void line(int x, int y, int z);
void colors(void);
void lines(void);
int current_year;
int rem;
}; // end of class
class dates //declaration for class "date"
{
private:
int date;
int month;
int year;
public:
void enter_date();
void show_date();
}; //end of class "date"
departmental d1;
extra e1;
dates D1;
void extra:: colors(void) // for background color
{
for (i=0; i<26; i++)
{
for (j=0; j<80; j++)
cprintf(" ");
textbackground(5);
}
}
int departmental:: check_id() // for generating unique id
{
fstream fp;
int k,j=1;
fp.open("customer.txt",ios::in);
k=0;
while(fp.read((char *)&d1,sizeof(d1)))
{
j=id;
k++;
}
fp.close();
if(k!=0)
j=j+1;
return j;
} // end of function
void extra::line1(int x,int m,int a) // function for drawing horizontal line
{
for(i=5;i<a;i++)
{
gotoxy(m,x);
cout<<"-";
m++;
}
}
void extra::line(int a,int m,int x) // function for drawing vertical line
{
for(i=0;i<x;i++)
{
gotoxy(a,m);
cout<<"|";
m++;
}
}
void extra::blink_message(char msg[]) // function for message blinking.
{
textbackground(8);
textcolor(YELLOW+BLINK);
gotoxy(30,8);
cprintf(msg);
cout<<"\n";
textcolor(YELLOW);
}
void extra::subblinkmessage(char msg[]) // subblinking message function.
{
textbackground(8);
textcolor(YELLOW+BLINK);
gotoxy(26,21);
cprintf(msg);
printf("\n");
textcolor(YELLOW);
}
void extra::lines(void) // drawing lines
{
for(i=0;i<80;i++)
cout<<"*";
}
void extra::music() // producing 7HZ sound .
{
sound(440);
delay(250);
nosound();
}
void extra::mainmenu() // showing main menu
{
e1.colors();
D1.show_date();
textbackground(BLUE);
textcolor(WHITE);
gotoxy(1,3);
cprintf(" DEPARTMENTAL STORE MANAGEMENT SYSTEM ");
gotoxy(1,4);
cprintf(" Birtamode,Jhapa ");
e1.lines();
textbackground(RED);
gotoxy(73,1);
cprintf("Close[X]");
textcolor(WHITE);
textbackground(7);
gotoxy(1,5);
cprintf(" ");
gotoxy(4,5);
textcolor(RED);
cprintf("F");
gotoxy(5,5);
textcolor(0);
cprintf("ile ");
gotoxy(16,5);
textcolor(RED);
cprintf("E");
gotoxy(17,5);
textcolor(0);
cprintf("dit ");
gotoxy(29,5);
textcolor(RED);
cprintf("S");
gotoxy(30,5);
textcolor(0);
cprintf("earch ");
gotoxy(44,5);
textcolor(RED);
cprintf("B");
gotoxy(45,5);
textcolor(0);
cprintf("illing ");
gotoxy(58,5);
textcolor(RED);
cprintf("H");
gotoxy(59,5);
textcolor(0);
cprintf("elp ");
gotoxy(68,5);
textcolor(RED);
cprintf("O");
gotoxy(69,5);
textcolor(0);
cprintf("ptions ");
gotoxy(1,22);
textcolor(WHITE);
e1.lines();
}
void dates::enter_date() // for date
{
clrscr();
cout<<"\n\nFirst of all I need the current date ..."<<"\n";
cout<<"\nYear : ";
cin>>year;
while(year<2000||year>10000)
{
clreol();
cout<<"\aInvalid input for year !!!"<<"\n";
clreol();
cout<<"Please enter the year correctly : "<<"\n";
cin>>year;
}
e1.current_year=year;
cout<<"Month : ";
clreol();
cin>>month;
while(month<=0||month>12) //if month is greater then 12 or less then 1
{
clreol();
cout<<"\nInvalid input for month !!!"<<"\n";
clreol();
cout<<"Please enter the month correctly : \a"<<"\n";
clreol();
cin>>month;
}
cout<<"Date : ";
clreol();
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:{
cin>>date;
while(date<1||date>31) //for months with 31 days
{
cout<<"\aInvalid date !!!"<<"\n";
cout<<"Again enter the date : "<<"\n";
clreol();
cin>>date;
}
break;
}
case 2:{
cin>>date; //for february
if(year%4==0)
{
while(date<0||date>29) //for leap year
{
cout<<"\aInvalid date !!!"<<"\n";
cout<<"Again enter the date : "<<"\n";
clreol();
cin>>date;
}
}
else
{
while(date<0||date>28) //for non-leap year
{
cout<<"\aInvalid date !!!"<<"\n";
cout<<"Again enter the date : "<<"\n";
clreol();
cin>>date;
}
}
break;
}
default:{ //for other months with 30 days
cin>>date;
while(date<1||date>30)
{
cout<<"\aInvalid date !!!"<<"\n";
cout<<"Again enter the date : "<<"\n";
clreol();
cin>>date;
}
break;
}
} //end of switch
} //end of function
void dates::show_date() // showing date function
{
clrscr();
cout<<"Hello....\nIt's ";
cout<<date;
e1.rem=date%10;
switch(date)
{
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:{
cout<<"th ";
goto over;
}
}
switch(e1.rem)
{
case 1:{
cout<<"st ";
break;
}
case 2:{
cout<<"nd ";
break;
}
case 3:{
cout<<"rd ";
break;
}
default:{
cout<<"th ";
break;
}
} //end of switch
over: //label for jump statement
switch(month)
{
case 1:{
cout<<"January , ";
break;
}
case 2:{
cout<<"February , ";
break;
}
case 3:{
cout<<"March , ";
break;
}
case 4:{
cout<<"April , ";
break;
}
case 5:{
cout<<"May , ";
break;
}
case 6:{
cout<<"June , ";
break;
}
case 7:{
cout<<"July , ";
break;
}
case 8:{
cout<<"August , ";
break;
}
case 9:{
cout<<"September , ";
break;
}
case 10:{
cout<<"October , ";
break;
}
case 11:{
cout<<"November , ";
break;
}
case 12:{
cout<<"December , ";
break;
}
}
//end of switch
cout<<year<<" \n";
}
//end of function
void main() // main declaration
{
clrscr();
textcolor(GREEN);
cout<<"\n\t %% %% %%";
cout<<"\n\t %% %% %% %%%%% %% %%%%%% %%%%%% %%%% %%%% %%%%%%";
cout<<"\n\t %% %% %% %% %% %% %% %% %% %%% %% %%";
cout<<"\n\t %% %% %% %%%%% %% %% %% %% %% %%% %% %%%%%%";
cout<<"\n\t %% %% %% %% %% %% %% %% %% % %% %%";
cout<<"\n\t %%%%%%%%%%% %%%%%% %%%%%%% %%%%%% %%%%%% %% % %% %%%%%% ";
cout<<"\n\n\t $$$$$$$$ $$$$$ ";
cout<<"\n\t $$ $ $ ";
cout<<"\n\t $$ $$$$$ ";
cout<<"\n\n\n COMPUTER PROJECT (******** ON DEPARTMENTAL STORE MANAGEMENT *******)";
cout<<"\n\n\t\t BY :-";
cout<<"\n\n\t\t\t* BHAWESH KAFLE"<<"\t BCA II ";
cout<<"\n\n\t\t\t* JEWAN SITOULA"<<"\t BCA II ";
cout<<"\n\n\t\t\t* DURGA SUBEDI "<<"\t BCA II ";
cout<<" \n\n\n\t\t press any KEY to continue: ";
getch();
clrscr();
char u[10],p[20],ch1,c,user[]="admin",pas[]="admin";
int n=0;
clrscr();
e1.colors();
e1.blink_message("User Authentication\n");
textcolor(RED);
gotoxy(20,10);
cprintf("Enter username and password(only 3 attempts)\n");
int i=0;
while(n<=2) // conditon for password entry
{
textbackground(BLUE);
textcolor(WHITE);
textbackground(BLUE);
textcolor(WHITE);
gotoxy(1,1);
cprintf(" DEPARTMENTAL STORE MANAGEMENT SYSTEM ");
gotoxy(1,2);
cprintf(" Birtamode,Jhapa ");
gotoxy(32,12);
cprintf(" ");
gotoxy(32,15);
cprintf(" ");
gotoxy(1,25);
cprintf(" ");
gotoxy(32,13);
cprintf(" Username: ");
gotoxy(32,14);
cprintf(" Password: ");
gotoxy(32,13);
cprintf(" Username:");
fflush(stdin);
cin>>u;
gotoxy(32,14);
fflush(stdin);
cprintf(" Password:");
ch1='\0';
i=0;
while(ch1!=13) // showing asterik sign in place of password
{
fflush(stdin);
ch1=getch();
if(ch1!=13 && ch1!=8)
{
putch('*');
p[i] = ch1;
i++;
}
}
p[i] ='\0';
fflush(stdin);
textcolor(YELLOW);
if(strcmp(user,u)==0 && strcmp(pas,p)==0)// comparing username and password
{
D1.enter_date();
d1.tasks();
}
else // password else part
{
e1.colors();
clrscr();
e1.blink_message("User Authentication!!");
textcolor(GREEN);
n++;
e1.music();
textbackground(RED);
gotoxy(1,7);
cprintf("\nSorry!! the username or password is incorrect. only %d trials left. enter again", 3-n);
fflush(stdin);
}
}
if(n==3)
{ // password last attempt
clrscr();
e1.colors();
e1.blink_message("User Authentication!!");
textbackground(RED);
gotoxy(1,7);
cprintf("\n You have used maximum attempts(3).Please contact with Administrator.");
sleep(3);
exit(1);
}
}
fstream fp,fp2,fp3,fp4; // declaring global files
void departmental::tasks() //declaration of functioin "tasks"
{
textcolor(YELLOW);
e1.mainmenu();
textbackground(RED);
gotoxy(30,23);
cprintf("Press [h/H] for help");
gotoxy(1,23);
cprintf("Enter your choice:");
int c=getche();
switch(c)
{
case 'f':case 'F': // file menu
textcolor(0);
textbackground(10);
gotoxy(1,6);
cprintf(" N:New record ");
gotoxy(1,7);
cprintf(" L:List record ");
gotoxy(1,8);
cprintf(" E: Exit ");
gotoxy(1,23);
cprintf("Enter your choice:");
char ch;
ch=getche();
if(ch==27)
d1.tasks();
else
switch(ch)
{
case 'n':case 'N': // for adding new record
d1.add_record();
d1.tasks();
case 'l':case 'L': // for listing records
e1.blink_message("Listing Record");
d1.show_record();
gotoxy(1,25);
cprintf("[Press any key to go to the main page!!");
getch();
d1.tasks();
case 'e':case 'E': // for exit from program
{
textbackground(RED);
e1.blink_message("Do you really want to exit.");
textbackground(BLUE);
gotoxy(37,10);
cprintf(" ");
gotoxy(37,11);
cprintf(" ");
gotoxy(37,12);
cprintf(" ");
gotoxy(37,13);
cprintf(" ");
gotoxy(37,14);
cprintf(" ");
textbackground(RED);
gotoxy(40,11);
cprintf("Exit");
gotoxy(38,13);
cprintf("[Y]");
gotoxy(43,13);
cprintf("[N]");
char ch=getch();
if(ch=='y')
exit(0);
else
d1.tasks();
}
default: // default choice
e1.blink_message("Wrong choice!!!");
e1.music();
sleep(1);
d1.tasks();
}
case 'e':case 'E': // edit menu
{
textbackground(10);
gotoxy(10,6);
cprintf(" M:modify record ");
gotoxy(10,7);
cprintf(" D:delete record ");
gotoxy(1,23);
cprintf("Enter your choice:");
ch=getche();
if(ch==27)
d1.tasks();
else
switch(ch)
{
case 'm':case 'M': //for modifying records
{
d1.update_record();
d1.tasks();
}
case 'd':case 'D': // for deleting records
{
d1.delete_record();
d1.tasks();
}
default: // for default choice
{
e1.subblinkmessage("Wrong choice!!!!");
e1.music();
sleep(1);
d1.tasks();
}
}
case 's':case 'S': // for searcing data
{
textbackground(10);
gotoxy(29,6);
cprintf(" N:By name ");
gotoxy(29,7);
cprintf(" D:By Id ");
gotoxy(1,23);
cprintf("Enter your choice:");
ch=getche();
if(ch==27)
d1.tasks();
else
switch(ch)
{
case 'n':case 'N': //search by name
{
d1.search_record_name();
d1.tasks();
}
case 'd':case 'D': // search by id
{
d1.search_record();
d1.tasks();
}
default: // for default choice
{
e1.subblinkmessage("Wrong choice!!!!");
e1.music();
sleep(1);
d1.tasks();
}
}
}
case 'b':case 'B': // for billing
{
d1.sales();
d1.tasks();
}
case 'h':case 'H': // for help menu
{
textbackground(9);
textcolor(YELLOW);
gotoxy(20,6);
cprintf("******Help Menu*****");
gotoxy(1,8);
cprintf(" For file menu:# press [f/F]: This menu helps you to add,view and exit. ");
gotoxy(1,10);
cprintf(" For Edit menu:# press [e/E]: This menu helps you to edit and delete record. ");
gotoxy(1,12);
cprintf(" For Search menu:# press [s/S]: This menu help you to search the record. ");
gotoxy(1,14);
cprintf(" For Billing :# press [b/B] : This menu helps you for billing ");
gotoxy(1,16);
cprintf(" For Help press:# press [h/H] : This is for help. ");
gotoxy(1,18);
cprintf(" For Option press:# [o/O] :This menu help you to show programmer details,report and notification.");
gotoxy(1,20);
cprintf("For exit option press [X] or goto to file menu and click[E].");
gotoxy(1,25);
cprintf("Press any key to go to main menu");
getch();
d1.tasks();
}
case 'o':case'O': // for option menu
textbackground(10);
gotoxy(65,6);
cprintf(" A:About us ");
gotoxy(65,7);
cprintf(" N:Notification ");
// gotoxy(65,8);
// cprintf(" R:Report ");
gotoxy(1,23);
cprintf("Enter your choice:");
ch=getche();
if(ch==27)
d1.tasks();
else
switch(ch)
{
case 'a':case 'A': // for displaying about software history
{
textbackground(3);
textcolor(YELLOW);
gotoxy(1,8);
cprintf("This project is the joint venture of Three programmers.");
gotoxy(30,10);
cprintf("Programmers Details");
gotoxy(12,13);
cprintf(" Name ");
gotoxy(6,15);
cprintf(" Bhawesh kafle ");
gotoxy(6,17);
cprintf(" jeewan sitoula ");
gotoxy(6,19);
cprintf(" Durga Subedi ");
gotoxy(36,13);
cprintf(" Address ");
gotoxy(34,15);
cprintf(" Dhulabari-5 ");
gotoxy(34,17);
cprintf(" Birtamod ");
gotoxy(34,19);
cprintf(" Birtamod ");
gotoxy(59,13);
cprintf(" Contact address ");
gotoxy(61,15);
cprintf(" 9804917581 ");
gotoxy(61,17);
cprintf(" 9814625572 ");
gotoxy(61,19);
cprintf(" 9814023453 ");
gotoxy(1,25);
cprintf("Press any key to go to main menu!!");
getch();
d1.tasks();
}
case 'n':case 'N': // for notifying stock
{
d1.notification();
getch();
d1.tasks();
}
/* case 'r':case 'R': //for showing account history
{
d1.report();
d1.tasks();
}
*/
default: // default choice
{
e1.subblinkmessage("Wrong choice!!!!");
e1.music();
sleep(1);
d1.tasks();
}
}
case 'x': case'X':
{
textbackground(RED);
e1.blink_message("Do you really want to exit.");
textbackground(BLUE);
gotoxy(37,10);
cprintf(" ");
gotoxy(37,11);
cprintf(" ");
gotoxy(37,12);
cprintf(" ");
gotoxy(37,13);
cprintf(" ");
gotoxy(37,14);
cprintf(" ");
textbackground(RED);
gotoxy(40,11);
cprintf("Exit");
gotoxy(38,13);
cprintf("[Y]");
gotoxy(43,13);
cprintf("[N]");
ch=getch();
if(ch=='y'| ch=='Y')
exit(0);
else
d1.tasks();
}
// default choice
default:
{
e1.subblinkmessage("Wrong choice!!!!");
e1.music();
sleep(1);
d1.tasks();
}
}
}
} //End of main
void departmental::add_record() //declaration of function "add_record"
{
clreol();
e1.mainmenu();
e1.blink_message("Adding Records");
fp.open("customer.txt",ios::binary|ios::app);
fflush(stdin);
e1.line1(7,23,35);
e1.line(22,7,12);
e1.line1(10,23,35);
e1.line1(12,23,35);
e1.line1(14,23,35);
e1.line1(16,23,35);
e1.line1(18,23,35);
e1.line(53,7,12);
gotoxy(24,11);
cprintf("Enter goods name ");
gotoxy(24,13);
cprintf("Enter goods price ");
gotoxy(24,15);
cprintf("Enter the quantity ");
gotoxy(25,10);
fflush(stdin);
id=d1.check_id();
gotoxy(24,11);
cprintf("Enter goods name: ");
gets(gname);
gotoxy(24,13);
cprintf("Enter goods price: ");
cin>>price;
fflush(stdin);
gotoxy(24,15);
cprintf("Enter the quantity: ");
cin>>quantity;
fp.write((char*)&d1,sizeof(d1));
fp.close();
gotoxy(24,17);
cprintf("Files successfully saved!!!");
gotoxy(24,17);
cprintf("Do you want more again[y/n]");
char ch;
ch=getche();
if(ch=='y'|ch=='Y')
d1.add_record();
} // end of function
void departmental::show_record() // declaration of function "show_record"
{
clreol();
e1.mainmenu();
int j=0;
fp.open("customer.txt",ios::in);
gotoxy(1,25);
e1.blink_message("Listing Record's");
textcolor(RED);
textbackground(3);
while(fp.read((char *)&d1,sizeof(d1)))
{
gotoxy(13,12+j);
cout<<d1.id<<"\t\t";
cout<<d1.gname<<"\t\t";
cout<<d1.quantity<<"\t\t";
cout<<d1.price<<"\t\t";
j++;
}
gotoxy(12,10);
cprintf(" Id Name Qty price \n");
e1.line1(7,11,61);
e1.line1(9,11,61);
e1.line1(11,11,61);
e1.line(10,7,13);
e1.line1(19,11,61);
e1.line(67,7,13);
e1.line(20,10,10);
e1.line(38,10,10);
e1.line(50,10,10);
fp.close();
} // end of function
void departmental::search_record() //declaration of function "search_record"
{
int d,i=0;
clreol();
fp.open("customer.txt",ios::in);
e1.blink_message("Searching Record");
e1.mainmenu();
fflush(stdin);
gotoxy(30,8);
cprintf("Enter ID for search:");
cin>>d;
while(fp.read((char *)&d1,sizeof(d1)))
{
if(id==d)
{
e1.blink_message(" Searched Record Found ");
textcolor(RED);
textbackground(3);
gotoxy(12,10);
cprintf(" Id Name Qty price \n");
gotoxy(12,12);
cout<<id<<"\t\t";cout<<gname<<"\t\t";cout<<quantity<<"\t\t";cout<<price<<"\t\t";
e1.line1(7,11,61);
e1.line1(9,11,61);
e1.line1(11,11,61);
e1.line(10,7,13);
e1.line1(19,11,61);
e1.line(67,7,13);
e1.line(20,10,10);
e1.line(38,10,10);
e1.line(50,10,10);
i++;
}
}
if(i==0)
{
e1.blink_message("Sorry!!! Record doesn't exist in our database!!\n");
}
fp.close();
gotoxy(1,25);
cprintf("Do you want to search again[y/n]");
int ch=getche();
if(ch=='y'|ch=='Y')
d1.search_record();
} // end of function
void departmental::search_record_name() //declaration of function for searching records by name
{
int i=0,j=0;char name[30];
clreol();
fp.open("customer.txt",ios::in);
e1.blink_message("Searching Record");
e1.mainmenu();
fflush(stdin);
gotoxy(30,8);
cprintf("Enter name for search:");
gets(name);
while(fp.read((char *)&d1,sizeof(d1)))
{
if( strcmp(name,gname)==0)
{
e1.blink_message(" Searched Record Found ");
textcolor(RED);
textbackground(3);
gotoxy(12,10);
cprintf(" Id Name Qty price \n");
gotoxy(12,12+j);
cout<<id<<"\t\t";cout<<gname<<"\t\t";cout<<quantity<<"\t\t";cout<<price<<"\t\t";
e1.line1(7,11,61);
e1.line1(9,11,61);
e1.line1(11,11,61);
e1.line(10,7,13);
e1.line1(19,11,61);
e1.line(67,7,13);
e1.line(20,10,10);
e1.line(38,10,10);
e1.line(50,10,10);
j++;
i++;
}
}
if(i==0)
{
e1.blink_message("Sorry !!! Record doesn't exist in our database!!\n");
}
fp.close();
gotoxy(1,25);
cprintf("Do you want to search again[y/n]");
int ch=getche();
if(ch=='y'|ch=='Y')
d1.search_record_name();
} // end of functioin
void departmental:: update_record() //declaration of functoin for modifying records
{
int k,d;
clreol();
d1.show_record();
e1.blink_message("Modifying Records");
k=0;
fp.open("customer.txt",ios::in);
fp2.open("test5.txt",ios::out);
fflush(stdin);
gotoxy(1,20);
cprintf("Enter the Id of goods to be modified:");
cin>>d;
while(fp.read((char *)&d1,sizeof(d1)))
{
if(id==d)
{
clreol();
e1.mainmenu();
fflush(stdin);
e1.blink_message("Modifying Record");
e1.line1(7,23,35);
e1.line(22,7,12);
e1.line1(10,23,35);
e1.line1(12,23,35);
e1.line1(14,23,35);
e1.line1(16,23,35);
e1.line1(18,23,35);
e1.line(53,7,12);
gotoxy(24,11);
cprintf("Enter goods name : ");
gotoxy(24,13);
cprintf("Enter goods price : ");
gotoxy(24,15);
cprintf("Enter the quantity: ");
char goods[30];
gotoxy(24,11);
cprintf("Enter goods name :");
gets(goods);
strcpy(gname,goods);
gotoxy(24,13);
cprintf("Enter goods price :");
cin>>new_price;
price=new_price;
gotoxy(24,15);
fflush(stdin);
cprintf("Enter the quantity:");
cin>> qty;
quantity=qty;
fp2.write((char *)&d1,sizeof(d1));
k++;
}
else
fp2.write((char *)&d1,sizeof(d1));
}
fp.close();
fp2.close();
remove("customer.txt");
rename("test5.txt","customer.txt");
if(k==0)
{
e1.subblinkmessage("Sorry!! Record doesn't exist in our database");
}
else
{
e1.subblinkmessage("Successful!!Record has been modified");
d1.show_record();
}
gotoxy(1,24);
cprintf("Do you want to modify more records [y/n]");
char ch=getche();
if(ch=='y'|ch=='Y')
d1.update_record();
} // end of function
void departmental::delete_record() // for deleting records
{
int d;
int j=0;
clreol();
d1.show_record();
fp.open("customer.txt",ios::in|ios::binary);
fp2.open("test5.txt",ios::out|ios::binary);
fflush(stdin);
e1.blink_message("Deleting Records");
gotoxy(1,20);
cprintf("Enter the id of the item to be deleted:");
cin>>d;
while(fp.read((char *)&d1,sizeof(d1)))
{
if(d==d1.id)
j++;
else
fp2.write((char *)&d1,sizeof(d1));
}
fp.close();
fp2.close();
remove("customer.txt");
rename("test5.txt","customer.txt");
if(j==0)
{
e1.subblinkmessage("Sorry !!!Record not exist in our database");
}
else
{
e1.subblinkmessage("Such Record is deleted from our database");
d1.show_record();
}
// e1.mainmenu();
// d1.show_record();
gotoxy(1,25);
cprintf("Do you want to delete another record?[y/n]");
char ch;
ch=getche();
if(ch=='y'|ch=='Y')
d1.delete_record();
} // end of function
// billing part
void departmental::sales() // declaration of function sales
{
char name[30],add[30],goods[30],ch;
double pro,test;
int d,a=0,s;
double k=0,vat,dis,gtot,n,x;
clreol();
e1.mainmenu();
fflush(stdin);
e1.blink_message("Enter the Following data");
e1.line1(7,23,48);
e1.line(22,7,7);
e1.line1(9,23,48);
e1.line1(11,23,48);
e1.line1(13,23,48);
e1.line(65,7,7);
//Entering customer details
fp2.open("test5.txt",ios::binary|ios::app);
fp4.open("backup.txt",ios::binary|ios::app);
gotoxy(23,10);
cprintf("Enter the name of customer :");
gotoxy(23,12);
cprintf("Enter the address of customer:");
gotoxy(23,10);
cprintf("Enter the name of customer :");
gets(name);
gotoxy(23,12);
cprintf("Enter the address of customer:");
gets(add);
fp2.write((char *)&d1,sizeof(d1));
fp4.write((char *)&d1,sizeof(d1));
fp2.close();
fp4.close();
e1.line(52,9,5);
xx:
clreol();
e1.mainmenu();
d1.show_record();
fp2.open("test5.txt",ios::binary|ios::app);
fp3.open("copy.txt",ios::out|ios::binary);
fp.open("customer.txt",ios::in|ios::binary);
fp4.open("backup.txt",ios::binary|ios::app);
// clrscr();
// clreol();
// e1.mainmenu();// function for main menu
// d1.show_record();
// e1.line1(7,23,35);
// e1.line(22,7,5);
// e1.line1(9,23,35);
// e1.line1(11,23,35);
// e1.line(53,7,5);
gotoxy(23,20);
cprintf("Enter the Id of the item:");
cin>>d;
fflush(stdin);
while(fp.read((char *)&d1,sizeof(d1)))
{
if(d==id)
{
a:
gotoxy(23,21);
fflush(stdin);
cprintf("Enter the qty of the item:");
cin>>qt;
// checking the stock.
if(qt>quantity)
{
e1.subblinkmessage("Out of stock!!.. Please enter qty again.");
getch();
goto a;
}
else
{ /*calculating the amount*/
a=quantity-qt;
quantity=a;
tc=qt*(float)price;
k=(float)k+tc;
tot=k;
n=((float)pro+0.00*tot);//calculating total profit
// prof=((float)prof+n);
vat=((float)0.13*tot);
// calculating discount percentage.
if (tot<1000)
dis=((float)0.00*tot);
else if(tot>=1000)
dis=((float)0.05*tot);
else if(tot>=3000)
dis=((float)0.10*tot);
else if( tot>=5000)
dis=((float)0.15*tot);
x=((float)(tot+vat)-dis); //calculating total sales
tot=x;
// stot=((float)stot+tot);
fp2.write((char *)&d1,sizeof(d1));
fp3.write((char *)&d1,sizeof(d1));
fp4.write((char *)&d1,sizeof(d1));
}
fp2.close();
fp4.close();
}
else
fp3.write((char *)&d1,sizeof(d1));
}
fp.close();
fp3.close();
remove("customer.txt");
rename("copy.txt","customer.txt");
gotoxy(23,23);
cprintf("Do yo have Any other items??[Y/N]\n");
ch=getche();
if(ch=='y'|ch=='Y')
goto xx;
fp2.open("test5.txt",ios::binary|ios::in);
clrscr();
e1.colors();
textcolor(RED);
textbackground(BLUE);
e1.line(10,1,24);
e1.line(70,1,24);
e1.line1(1,11,65);
int j=0;
while(fp2.read((char *)&d1,sizeof(d1)))
{
n=price;
// display of bill
gotoxy(11,2);
cprintf(" B & J Departmental Store ");
gotoxy(11,3);
cprintf(" Birtamode,jhapa ");
gotoxy(11,4);
cprintf(" Nepal ");
e1.line1(5,11,65);
gotoxy(37,5);
cprintf("TAX INVOICE");
e1.line1(9,11,65);
gotoxy(11,6);
cprintf(" Regd no:10432223");
gotoxy(11,7);
cout<<"Name :"<<name;
gotoxy(11,8);
cout<<"Addrress :"<<add;
gotoxy(12,10);
cprintf(" Sn Particulars Qty Rate Amount(Rs)");
e1.line1(11,11,65);
fflush(stdin);
gotoxy(13,11+j);
cout<<j<<" \t";cout<<gname<<"\t\t";cout<<qt<<"\t ";cout<<n<<"\t ";cout<<tc<<"\n";
// cout<<"\n";
j++;
}
e1.line(45,10,9);
e1.line(35,10,9);
e1.line(16,10,9);
e1.line(56,10,15);
e1.line1(18,11,65);
gotoxy(50,19);
cprintf("Total:");
gotoxy(58,19);
cout<<k;
e1.line1(20,11,65);
gotoxy(52,21);
cprintf("Vat:");
gotoxy(58,21);
printf("%.2f",vat);
gotoxy(52,22);
cprintf("Dis:");
gotoxy(58,22);
cout<<dis;
gotoxy(44,23);
cprintf("Grand total:");
gotoxy(58,23);
printf("%.2f",tot);
gotoxy(1,25);
cprintf("Press any key to exit from this bill.!!!!");
e1.line1(24,11,65);
fp2.close();
fp4.close();
remove("test5.txt");
getch();
e1.colors();
gotoxy(20,13);
cout<<"@@@@@@@ Thanks for you kind visit @@@@@@@";
gotoxy(1,24);
cout<<"Press any key to go to the main menu";
getch();
} // end of function
/* void departmental::report() // declaration of function report
{
fp4.open("backup.txt",ios::out|ios::binary);
while(fp4.read((char *)&d1,sizeof(d1)))
gotoxy(30,12);
cout<<"Total sales made :"<<stot;
gotoxy(30,14);
cout<<"Total profit made:"<<prof;
getch();
fp4.close();
}
{
float k;
FILE *fp4;
fp4=fopen("backup.txt","r");
gotoxy(10,10);
printf("invoice id Name Price sales person");
gotoxy(10,11);
printf("---------------------------------------------------------------");
j=0;
while(fread(&c,sizeof(c),1,fp4)==1)
{
textcolor(WHITE);
gotoxy(10,12+j);
printf(" %s %.2f ",c.name,c.test);
j++;
}
fclose(fp4);
getch();
}
*/
void departmental::notification() // declaration of function notification
{
fstream fp;
int j=0;
fp.open("customer.txt",ios::in|ios::binary);
e1.blink_message("*** Stock Notification ***");
gotoxy(15,10);
cprintf("Stock Id Name report");
while(fp.read((char *)&d1,sizeof(d1)))
{
if(quantity<=10)
{
gotoxy(11,11+j);
cout<<"\t"<<id;cout<<"\t\t\t"<<gname;cout<<"\t\t*Low";
}
else if(quantity>=10&&quantity<=59)
{
gotoxy(11,11+j);
cout<<"\t"<<id;cout<<"\t\t\t"<<gname<<"\t\tMedium";
}
else if(quantity>=60)
{
gotoxy(11,11+j);
cout<<"\t"<<id;cout<<"\t\t\t"<<gname;cout<<"\t\t GOOD";
}
j++;
}
fp.close();
e1.subblinkmessage("Press any key to go to main menu!!!!!");
}
Berikut adalah contoh tampilan outputnya
Tidak ada komentar:
Posting Komentar