Платежная ведомость предприятияРефераты >> Программирование и компьютеры >> Платежная ведомость предприятия
q->write( (char*)&ved, sizeof(ved) );
else
{q->close();
q->open(fname, ios::in|ios::binary);
for (int i=0; i<kol; i++)
{
q->read( (char*)&vedread, sizeof(vedread) );
if (strcmp(vedread.nazva,name))
k++;
}
if (k!=kol)
{
q->close();
q->open(fname, ios::app|ios::binary);
q->write( (char*)&ved, sizeof(ved) );
}
else
{
cout<<"DANNAYA ZIPIS' NE MOZET BIT SOHRANENA\n";
cout<<"Tacaia familia uje sozdana\n";
}
}
}
cout << "PRODOLZIT VVOD?(Y/N) ";
cin >> otv;
}
while ((otv!='N')&&(otv!='n'));
q->close();
}
////////////////////////////////////////////////////////////////////////////
void vvod(predpr *p)
{
char name[15] ;
cout<<"\nVVEDITE Familiu\n";
cout << "Familia (NE BOLEE 15 SIMVOLOV) - ";
cin >> p->nazva;
cout << "Zarobotnaya plata - ";
cin >> p->valprod;
cout << "Uderjano - ";
cin >> p->kolrab;
p->proizv=p->valprod/p->kolrab;
cout << "Vidano - ";
cout << p->proizv<<endl;
}
////////////////////////////////////////////////////////////////////////////
void pech(fstream *q)
{
int kol;
float svalprod=0;
int skolrab=0;
float sproizv=0;
clrscr();
cout << "VVEDITE IM'YA FAILA: ";
char fname[8];
cin >> fname;
q->open(fname, ios::app|ios::binary|ios::nocreate);
if (!*q) {
cout << "NET FAILA S TAKIM IMENEM\n";
return; }
q->seekp(0, ios::end);
kol=q->tellp()/sizeof(predpr);
q->close();
q->open(fname, ios::in|ios::binary);
if (*q)
{ clrscr();
cout<<"-----------------------------------------------------------------------\n";
cout<<"| N | Familia | Zarplata | Uderjano | Vidano |\n";
cout<<"|p/p| | grn | grn | grn |\n";
cout<<"-----------------------------------------------------------------------\n";
for (int i=0; i<kol; i++)
{ q->read( (char*)&ved, sizeof(ved) );
cout<<"|";
cout<<setw(3)<<(i+1)<<"|";
cout.setf(ios::left);
cout<<setw(21)<<ved.nazva<<"|";
cout.setf(ios::fixed);
cout.setf(ios::right);
cout<<setprecision(2);
cout<<setw(11)<<ved.valprod<<"|";
svalprod+=ved.valprod;
cout<<setw(11)<<ved.kolrab<<"|";
skolrab+=ved.kolrab;
cout<<setw(10)<<ved.proizv<<"|"<<endl;
sproizv+=ved.proizv;
}
cout<<"-----------------------------------------------------------------------\n";
cout<<"| | ITOGO|";
cout<<setw(11)<<svalprod<<"|";
cout<<setw(11)<<skolrab<<"|";
cout<<setw(10)<<sproizv<<"|"<<endl;
cout<<"-----------------------------------------------------------------------\n";
}
q->close();
// cout.unsetf();
}
///////////////////////////////////////////////////////////////////////////
void pause()
{
cout << "DLA PRODOLGENIA NAGMITE \"Enter\"\n";
while ( getch() != 13) ;
}
////////////////////////////////////////////////////////////////////////////
void dopolnen(fstream *q)
{ char otv;
predpr vedread;
int kol,k=1;
clrscr();
cout << "VVEDITE IM'YA DOPOLN'AEMOGO FAILA: ";
char fname[8],*name;
cin>>fname;
q->open(fname, ios::app|ios::binary|ios::nocreate);
if (!*q) {
cout<<"NET FAILA S TAKIM IMENEM!\n";
return; }
do
{ vvod(&ved);
k=1;
name=ved.nazva;
q->seekp(0, ios::end);
kol=q->tellp()/sizeof(predpr);
if (*q)
{
q->close();
q->open(fname, ios::in|ios::binary);
for (int i=0; i<kol; i++)
{
q->read( (char*)&vedread, sizeof(vedread) );
if (strcmp(vedread.nazva,name))
k++;
}
if (k!=kol)
{
q->close();
q->open(fname, ios::app|ios::binary);
q->write( (char*)&ved, sizeof(ved) );
}
else
{
cout<<"DANNAYA ZIPIS' NE MOZET BIT SOHRANENA\n";
cout<<"Tacaya Familia uze est\n";
}
}
cout << "PRODOLGIT DOPOLNENIE?(Y/N) ";
cin >> otv;
} while ((otv!='N')&&(otv!='n'));
q->close();
}
////////////////////////////////////////////////////////////////////////////
void korr(fstream *q)
{
char n[15];
clrscr();
cout << "VVEDITE IM'YA KORREKTIRUEMOGO FAILA: ";
char fname[8];
cin >> fname;
q->open(fname, ios::in|ios::out|ios::binary|ios::nocreate);
if (!*q) {
cout << "NEVOZMOGNO OTKRIT FAIL!\n"
<< "TAKOGO FAILA NET\n";
return; }
do
{clrscr();
cout << "Vvedite redactiruumyu familiu: ";
cin>>n;
do
{
q->read( (char*)&ved, sizeof(ved) );
} while (*q && strcmp(ved.nazva,n) );
if (!strcmp(ved.nazva,n))
{ vvod(&ved);
q->seekp(-streamoff(sizeof(predpr)),ios::cur);
q->write( (char*)&ved, sizeof(ved) );
}
else
cout << "Familia " << n << " NE NAIDENA!\n";
q->seekp(0);
cout << "PRODOLGIT KORREKTIROVKU?(Y/N) ";
cin >> otv;
} while ((otv!='N')&&(otv!='n'));
q->close();
}
////////////////////////////////////////////////////////////////////////////
void iskl(fstream *q)
{
ofstream vspom;
char isk[15];
int col=0;
char fname[8];
cout << "VVEDITE IM'YA TREBUEMOGO FAILA: ";
cin >> fname;
clrscr();
do
{
q->open(fname, ios::in|ios::binary);
vspom.open("vsp",ios::out|ios::binary);
if ( *q && vspom )
{
cout << "Vvedite udaliaimuy familiu: ";
cin >> isk;
do
{
q->read( (char*)&ved, sizeof(ved) );
if (q->eof()) break;
if (!strcmp(ved.nazva,isk))
col=1;
else
vspom.write( (char*)&ved, sizeof(ved) );
} while ( *q );
q->close();
vspom.close();
if (col)
{
remove(fname);
rename("vsp", fname);
cout << "ZAPIS UDALENA "<<endl;
}
else