پروژه انبارداری
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
#include<iostream.h>
#include<stdlib.h>
#include<dos.h>
char ddate[20];
struct kala
{
char name[20];
long pol;
int tedad;
char seller[20];
char codKala[20];
};
struct vkala
{
char name[20];
int tedad;
char seller[20];
char codKala[20];
int v;
char date[10];
};
class classKala
{
kala allKala[200];
int countKala;
public :
classKala(){
countKala=0;
fillArrayKala();
}
void sabtkala(char karbar[20]);
void nemayeshKala(char karbar[20]);
void nemayeshKala();
void fillArrayKala();
void hazfKala();
void hazfKala(char karbar[20]);
void vorodkorojkala(char idkala[20],char karbar[20],int in);
void classKala::sabtVkala(char user[20],int ink,kala stin,int num);
void classKala::gozaresh();
};
//ink 1 for vared 0 for khoroj
void classKala::vorodkorojkala(char idkala[20],char karbar[20],int ink)
{
kala st;
clrscr();
ifstream in("kala",ios::in |ios::binary);
ofstream out("temp",ios::out | ios::binary);
while(in.read((char *) &st, sizeof(struct kala)))
{
if(strcmp(idkala, st.codKala)!=0)
out.write((char *) &st,sizeof(struct kala));
else
{
cout<<"enter num of kala("<<st.tedad<<")n";
int id;
cin>>id;
if(ink==1)
{
st.tedad=st.tedad+id;
sabtVkala(karbar,ink,st,id);
}
else
{
if(st.tedad-id<0)
cout<<"n kala beh andazeh kafi mojod nist";
else
{
st.tedad=st.tedad-id;
sabtVkala(karbar,ink,st,id);
}
}
out.write((char *) &st,sizeof(struct kala));
}
}
in.close();
out.close();
remove("kala");
rename("temp","kala");
fillArrayKala();
return;
}
void classKala::sabtkala(char user[20])
{
clrscr();
kala st;
int row=1;
gotoxy(5,row);
cout<<"name:";
gotoxy(25,row);
cin>>st.name;
row++;
gotoxy(5,row);
cout<<"geymat:";
gotoxy(25,row);
cin>>st.pol;
row++;
gotoxy(5,row);
cout<<"tedad:";
gotoxy(25,row);
cin>>st.tedad;
strcpy(st.seller,user);
row++;
gotoxy(5,row);
cout<<"code kala:";
gotoxy(25,row);
cin>>st.codKala;
row++;
char c;
gotoxy(5,row);
cout<<"aya mayel beh zakhireh hastid ? (y/n)";
c=getch();
if(c=='y')
{
ofstream out("kala",ios::app |ios::binary);
out.write((char *) &st,sizeof(struct kala));
out.close();
fillArrayKala();
}
}
void classKala::sabtVkala(char user[20],int ink,kala stin,int num)
{
clrscr();
vkala st;
strcpy(st.seller,user);
strcpy(st.codKala,stin.codKala);
strcpy(st.name,stin.name);
st.tedad=num;
st.v=ink;
strcpy(st.date,ddate);
ofstream out("vkala",ios::app |ios::binary);
out.write((char *) &st,sizeof(struct vkala));
out.close();
}
void classKala::fillArrayKala()
{
clrscr();
ifstream in("kala",ios::in |ios::binary);
countKala=0;
while(in.read((char *) &allKala[countKala], sizeof(struct kala)))
{
countKala++;
}
in.close();
}
void classKala::nemayeshKala()
{
int row=4,i=0;
clrscr();
cout<<"name geymat tedad karbar code "<<endl;
cout<<"÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷"<<endl;
while(i < countKala)
{
gotoxy(1,row);
cout<<allKala[i].name;
gotoxy(15,row);
cout<<allKala[i].pol;
gotoxy(25,row);
cout<<allKala[i].tedad;
gotoxy(35,row);
cout<<allKala[i].seller;
gotoxy(50,row);
cout<<allKala[i].codKala;
row++;
i++;
}
getch();
}
void classKala::gozaresh()
{
int row=4,i=0;
clrscr();
ifstream in("vkala",ios::in |ios::binary);
clrscr();
cout<<"name tedad tavasot codekala vorod tarikh "<<endl;
cout<<"÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷"<<endl;
vkala vk;
while(in.read((char *) &vk, sizeof(struct vkala)))
{
gotoxy(1,row);
cout<<vk.name;
gotoxy(15,row);
cout<<vk.tedad;
gotoxy(25,row);
cout<<vk.seller;
gotoxy(35,row);
cout<<vk.codKala;
gotoxy(50,row);
cout<<vk.v;
gotoxy(60,row);
cout<<vk.date;
row++;
i++;
}
in.close();
getch();
}
void classKala::nemayeshKala(char user[20])
{
int row=4,i=0;
clrscr();
cout<<"name geymat tedad karbar code "<<endl;
cout<<"÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷"<<endl;
while(i < countKala)
{
if(strcmp(allKala[i].seller,user)==1)
{
gotoxy(1,row);
cout<<allKala[i].name;
gotoxy(15,row);
cout<<allKala[i].pol;
gotoxy(25,row);
cout<<allKala[i].tedad;
gotoxy(35,row);
cout<<allKala[i].seller;
gotoxy(50,row);
cout<<allKala[i].codKala;
row++;
}
i++;
}
getch();
}
void classKala::hazfKala(char user[20])
{
char id[20];
kala st;
clrscr();
ifstream in("kala",ios::in |ios::binary);
ofstream out("temp",ios::out | ios::binary);
gotoxy(20,1);
cout<<" code kala (delet)n" ;
gotoxy(20,2);
cin>>id;
while(in.read((char *) &st, sizeof(struct kala)))
{
if(strcmp(user,st.seller)!=0 &&strcmp(id, st.codKala)!=0)
out.write((char *) &st,sizeof(struct kala));
}
in.close();
out.close();
remove("kala");
rename("temp","kala");
fillArrayKala();
}
void classKala::hazfKala()
{
char id[20];
char user[20];
kala st;
clrscr();
ifstream in("kala",ios::in |ios::binary);
ofstream out("temp",ios::out | ios::binary);
gotoxy(20,1);
cout<<" name karbar n" ;
gotoxy(20,2);
cin>>user;
gotoxy(20,3);
cout<<" code kalan" ;
gotoxy(20,4);
cin>>id;
while(in.read((char *) &st, sizeof(struct kala)))
{
if(strcmp(user, st.seller)!=0 &&strcmp(id, st.codKala)!=0)
out.write((char *) &st,sizeof(struct kala));
}
in.close();
out.close();
remove("kala");
rename("temp","kala");
fillArrayKala();
}
struct ashkhas
{
char name[30];
char tel[15];
char emaile[30];
char user[20];
char pas[20];
int typeShakhs;
} ;
class classAshkhas
{
classKala kala;
ashkhas allAshkhas[300];
int countAshkhas;
public:
// 1 for foroshandegan 2 for admin
classAshkhas();
void addAshkhas(int type);
void showAshkhas(int type);
void fillArrayAshkhas();
void delAshkhas(int type);
int logAshkhas(char user[20],char pas[20],int type);
void menu();
};
classAshkhas::classAshkhas()
{
countAshkhas=0;
fillArrayAshkhas();
}
void classAshkhas::menu()
{
int s =0;
char user[20],pas[20];
while(s<4)
{
clrscr();
gotoxy(20,1);
cout<<"1...........modir";
gotoxy(20,2);
cout<<"2...........karbar";
gotoxy(20,3);
cout<<"3...........sabt karbar ";
gotoxy(20,4);
cout<<"4...........exit";
gotoxy(20,5);
cin>>s;
if(s==1)
{
clrscr();
cout<<"enter usern";
cin>>user;
cout<<"enter pasn";
cin>>pas;
if(logAshkhas(user,pas,3)==1 || (strcmp(user,"123")==0 && strcmp(pas,"123")==0))
{
int s1=0;
while(s1<9)
{
clrscr();
gotoxy(20,1);
cout<<"1...........nemayesh kala";
gotoxy(20,2);
cout<<"2...........hazf kala";
gotoxy(20,3);
cout<<"3...........nemayesh karbar";
gotoxy(20,4);
cout<<"4...........hazf karbar ";
gotoxy(20,5);
cout<<"5...........hazf modir ";
gotoxy(20,6);
cout<<"6...........nemayesh modir ";
gotoxy(20,7);
cout<<"7...........ezafeh kardan modir";
gotoxy(20,8);
cout<<"8...........gozaresh";
gotoxy(20,9);
cout<<"9...........return ";
gotoxy(20,10);
cin>>s1;
if(s1==1)
kala.nemayeshKala();
else if(s1==2)
kala.hazfKala();
else if(s1==3)
showAshkhas(1);
else if(s1==4)
delAshkhas(0);
else if(s1==5)
delAshkhas(3);
else if(s1==6)
showAshkhas(3);
else if(s1==7)
addAshkhas(3);
else if(s1==8)
kala.gozaresh();
}
}
}
else if(s==2)
{
clrscr();
cout<<"enter usern";
cin>>user;
cout<<"enter pasn";
cin>>pas;
if(logAshkhas(user,pas,1)==1)
{
int s2=0;
while(s2<6)
{
clrscr();
gotoxy(20,1);
cout<<"1...........nemayesh kala";
gotoxy(20,2);
cout<<"2...........hazf kala";
gotoxy(20,3);
cout<<"3...........ezafeh kala";
gotoxy(20,4);
cout<<"4...........vorod kala";
gotoxy(20,5);
cout<<"5...........khoroj kala";
gotoxy(20,6);
cout<<"6...........return";
gotoxy(20,7);
cin>>s2;
if(s2==1)
kala.nemayeshKala();
else if(s2==2)
kala.hazfKala(user);
else if(s2==3)
kala.sabtkala(user);
else if (s2==4)
{
char idkala[20];
cout<<"n enter id kalan";
cin>>idkala;
kala.vorodkorojkala(idkala,user, 1);
}
else if(s2==5)
{
char idkala1[20];
cout<<"n enter id kalan";
cin>>idkala1;
kala.vorodkorojkala(idkala1,user, 0);
}
}
}
}
else if(s==3)
{
addAshkhas(1);
}
}
}
void classAshkhas::fillArrayAshkhas()
{
ifstream in("ashkhas",ios::in |ios::binary);
countAshkhas=0;
while(in.read((char *) &allAshkhas[countAshkhas], sizeof(struct ashkhas)))
{
countAshkhas++;
}
in.close();
}
void classAshkhas::addAshkhas(int typeShakhs)
{
clrscr();
ashkhas st;
int row=1;
gotoxy(5,row);
cout<<"name:";
gotoxy(25,row);
cin>>st.name;
row++;
gotoxy(5,row);
cout<<"telefon:";
gotoxy(25,row);
cin>>st.tel;
row++;
gotoxy(5,row);
cout<<"email:";
gotoxy(25,row);
cin>>st.emaile;
row++;
gotoxy(5,row);
cout<<"user:";
gotoxy(25,row);
cin>>st.user;
row++;
gotoxy(5,row);
cout<<"pas:";
gotoxy(25,row);
cin>>st.pas;
st.typeShakhs=typeShakhs;
row++;
char c;
gotoxy(5,row);
cout<<"aya mayel beh zakhireh hastid ? (y/n)";
c=getch();
if(c=='y')
{
ofstream out("ashkhas",ios::app |ios::binary);
out.write((char *) &st,sizeof(struct ashkhas));
out.close();
}
fillArrayAshkhas();
}
int classAshkhas::logAshkhas(char user[20],char pas[20],int type)
{
ashkhas st;
int i =0;
while(i<countAshkhas)
{
if(strcmp(user, allAshkhas[i].user)==0 &&strcmp(pas, allAshkhas[i].pas)==0 && allAshkhas[i].typeShakhs==type)
{
return 1;
}
i++;
}
return 0;
}
void classAshkhas::showAshkhas(int typeAshkhas)
{
int row=4,i=0;
char name[30];
char tel[15];
char emaile[30];
char user[20];
char pas[20];
int typeShakhs;
clrscr();
cout<<"nname telfon emaile user pas ";
cout<<"n÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷÷";
while(i < countAshkhas)
{
if(allAshkhas[i].typeShakhs==typeAshkhas)
{
gotoxy(1,row);
cout<<allAshkhas[i].name;
gotoxy(20,row);
cout<<allAshkhas[i].tel;
gotoxy(25,row);
cout<<allAshkhas[i].emaile;
gotoxy(35,row);
cout<<allAshkhas[i].user;
gotoxy(50,row);
cout<<allAshkhas[i].pas;
row++;
}
i++;
}
getch();
}
void classAshkhas::delAshkhas(int type)
{
char user[20];
clrscr();
ashkhas st;
clrscr();
ifstream in("ashkhas",ios::in |ios::binary);
ofstream out("temp",ios::out | ios::binary);
gotoxy(20,5);
cout<<" vare konid name karbari ra" ;
gotoxy(20,6);
cin>>user;
while(in.read((char *) &st, sizeof(struct ashkhas)))
{
if(strcmp(user, st.user)!=0 && st.typeShakhs != type )
out.write((char *) &st,sizeof(struct ashkhas));
}
in.close();
out.close();
remove("ashkhas");
rename("temp","ashkhas");
fillArrayAshkhas();
}
int main(void)
{
clrscr();
cin>>ddate;
classAshkhas cl ;
cl.menu();
return 0;
}


مقالات و تحقیق ها با فرمت ورد\الگوریتم های مرتب سازی
دانلود سورس برنامه حسابداری به زبان ویژوال بیسیک