#include <fstream.h>
#include <graphics.h>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
void mainpage(void);
void pagek(void);
void pagem(void);
void pagea(void);
struct information {
int codem;
char telm[10];
char namem[20];
char adressm[20];
} infom;
struct inkala {
int codek;
char namek[20];
char datek[20];
int tedadk;
} infok;
struct inanbar {
int codem;
int codek;
char date1[10];
int tedad;
} infoa;
int xy = 8;
void sabtm(void)
{
fstream fmosh(“mosh.dat”, ios::in | ios::out | ios::binary);
if(!fmosh) {
cout << “Cannot open file.”;
exit(0);
}
fmosh.seekp(0,ios::end);
gotoxy(17,10);
cout << “code tel ”
<< ” name adress “<<endl;
gotoxy(17, 12);
cin >> infom.codem;
gotoxy(27, 12);
cin >> infom.telm;
gotoxy(37, 12);
cin >> infom.namem;
gotoxy(47, 12);
cin >> infom.adressm;
cin.get();
fmosh.write((char *) &infom, sizeof(struct information));
fmosh.close();
getch();
pagem();
}
/////////////////////////////////////////
void sabtk(void)
{
fstream fkala(“kala.dat”, ios::in | ios::out | ios::binary);
if(!fkala) {
cout << “Cannot open file.”;
exit(0);
}
fkala.seekp(0,ios::end);
gotoxy(17,10);
cout << “code ”
<< ” name tarikh tedad”<<endl;
gotoxy(17, 12);
cin >> infok.codek;
gotoxy(27, 12);
cin >> infok.namek;
gotoxy(37, 12);
cin >> infok.datek ;
gotoxy(47, 12);
cin >> infok.tedadk;
cin.get();
fkala.write((char *) &infok, sizeof(struct inkala));
fkala.close();
getch();
pagek();
}
/////////////////////
int findkk(int ss)
{
int f=0;
gotoxy(13,9);
cout << ” ” ;
gotoxy(17,10);
ifstream temp(“kala.dat”, ios::out | ios::binary);
while(temp.read((char *) &infok, sizeof(struct inkala))) {
if (infok.codek==ss)
f=1;
}
return f;
}
void sabta(void)
{
fstream fanbar(“anbar.dat”, ios::in | ios::out | ios::binary);
if(!fanbar) {
cout << “Cannot open file.”;
exit(0);
}
int sd,h;
gotoxy(17, 8);
cout << ” Enter your code kala:”;
cin >> sd;
if (findkk(sd))
{
fanbar.seekp(0,ios::end);
gotoxy(17, 10);
cout << ” Enter your tedad kala:”;
cin >> h;
gotoxy(17, 12);
cin >> infoa.codem;
gotoxy(27, 12);
cin >> infoa.codek;
gotoxy(37, 12);
cin >> infoa.date1 ;
cin.get();
fanbar.write((char *) &infoa, sizeof(struct inanbar));
fanbar.close();
}
else
cout<<“code kala eshtebah”;
getch();
pagea();
}
////////find///////////////
void findm(void)
{
int sd;
gotoxy(13,9);
cout << ” ” ;
gotoxy(17,10);
cout << ” Enter your code mostary:”;
cin >> sd;
ifstream temp(“mosh.dat”, ios::out | ios::binary);
gotoxy(17,12);
cout << ” code tel ”
<< ” name adress “<<endl;
while(temp.read((char *) &infom, sizeof(struct information))) {
if (infom.codem==sd)
{
gotoxy(17, 14);
cout << infom.codem ;
gotoxy(27, 14);
cout << infom.telm ;
gotoxy(37, 14);
cout << infom.namem;
gotoxy(47, 14);
cout << infom.adressm;
}
}
getch();
pagem();
}
////////////////
void edit(void)
{
int sd;
ifstream file1(“kala.dat”, ios::out | ios::binary);
ofstream file2(“kala1.dat”, ios::out | ios::binary);
if(!file1 && !file2) {
cout << “Cannot open file.”;
getch();
exit(0);
}
gotoxy(17,10);
cout << “Enter code kala:”;
cin >> sd;
while(file1.read((char *) &infok, sizeof(struct inkala))) {
if (infok.codek==sd)
{
int y=0;
gotoxy(17,12);
cout << “Enter tedad jahate afzaiesh:”;
cin >> y;
y=infok.tedadk+y;
infok.tedadk=y;
file2.write((char *) &infok, sizeof(struct inkala));
file1.close();
file2.close();
remove(“kala.dat”);
rename(“kala1.dat”, “kala.dat”);
}
else
cout<<“code kala eshtebah ast”;
}
getch();
pagek();
}
|
دیدگاهتان را بنویسید