#include #include #include #include #include #include /*struct date { int da_year; /* current year char da_day; /* day of the month char da_mon; /* month (1 = Jan) };*/ /***** INICIA CLASE CLIENTES *****/ class clientes{ public: char codigo[10]; char nombre[35]; char direc[40]; char col[20]; char ciudad[20]; char estado[15]; char CP[10]; char tel[15]; int pel_cargo; struct date fecha; void capturar(); void generar(); void mostrar(); int buscar(char x[]); void eliminar(char x[]); void modificar(char x[]); void be_nom(char x[]); void be_ade(); void be_ciu(char x[]); }cl; void clientes::capturar(){ cout<<" Cądigo: "; cin>>codigo; cout<<" Nombre: "; gets(nombre); cout<<" Direcciąn: "; gets(direc); cout<<" Colonia: "; gets(col); cout<<" Ciudad: "; gets(ciudad); cout<<" Estado: "; gets(estado); cout<<" Cądigo Postal: "; gets(CP); cout<<" Tel‚fono: "; gets(tel); pel_cargo=0; getdate(&fecha); } void clientes::generar(){ ofstream z("a:\\clientes.txt",ios::app); z.write((char *)&cl,sizeof(cl)); z.close(); } void clientes::mostrar(){ ifstream z("a:\\clientes.txt"); clrscr(); while(!z.eof()&&!z.fail()){ z.read((char *)&cl,sizeof(cl)); if(z.eof()) break; cout<<" Cądigo: "<>opc; if(opc=='s'||opc=='S'){ ifstream z("a:\\clientes.txt"); ofstream x("a:\\auxiliar.txt"); while(!z.eof()&&!z.fail()){ z.read((char *)&cl,sizeof(cl)); if(strcmp(cod,codigo)==0){ if(pel_cargo>0) cout<<"\n El cliente aŁn tiene pelĄculas a cargo. No se puede dar de baja. "; else z.read((char *)&cl,sizeof(cl)); } else x.write((char *)&cl,sizeof(cl)); } z.close(); x.close(); unlink("a:\\clientes.txt"); rename("a:\\auxiliar.txt","a:\\clientes.txt"); cout<<"\n El cliente ha sido dado de baja."; } else cout<<"\n El cliente no ha sido dado de baja. "; } getch(); } void clientes::modificar(char cod[]){ char opc; if(cl.buscar(cod)!=0); cout<<"\n\n Este es el cliente con ese cądigo. šDeseas modificar sus datos? (s/n) "; cin>>opc; if(opc=='s'||opc=='S'){ ifstream z("a:\\clientes.txt"); ofstream x("a:\\auxiliar.txt"); clrscr(); while(!z.eof()&&!z.fail()){ z.read((char *)&cl,sizeof(cl)); if(strcmp(cod,codigo)==0){ cout<<" Nombre: "; gets(nombre); cout<<" Direcciąn: "; gets(direc); cout<<" Colonia: "; gets(col); cout<<" Ciudad: "; gets(ciudad); cout<<" Estado: "; gets(estado); cout<<" Cądigo Postal: "; gets(CP); cout<<" Tel‚fono: "; gets(tel); x.write((char *)&cl,sizeof(cl)); z.read((char *)&cl,sizeof(cl)); } else x.write((char *)&cl,sizeof(cl)); } z.close(); x.close(); unlink("a:\\clientes.txt"); rename("a:\\auxiliar.txt","a:\\clientes.txt"); cout<<"\n Los datos del cliente han sido modificados correctamente."; cout<<"\n\n Estos son los nuevos datos:"; getch(); buscar(cod); } else cout<<"\n Los datos del cliente no han sido modificados."; getch(); } void clientes::be_nom(char nom[]){ char *tmpstr,nmb[35]; ifstream z("a:\\clientes.txt"); while(!z.eof()&&!z.fail()){ z.read((char *)&cl,sizeof(cl)); strcpy(nmb,nombre); tmpstr=strstr(strupr(nmb),strupr(nom)); if(tmpstr!=NULL&&!z.eof()){ cout<<" Cądigo: "<0&&!z.eof()){ cout<<" Cądigo: "<>codigo; cout<<"Nombre: "; gets(nombre); cout<<"G‚nero: "; gets(genero); cout<<"Clasificaciąn: "; gets(clasif); disp=5; } void peliculas::generar(){ ofstream z("a:\\pelis.txt",ios::app); z.write((char *)&pel,sizeof(pel)); z.close(); } void peliculas::mostrar(){ ifstream z("a:\\pelis.txt"); while(!z.eof()&&!z.fail()){ z.read((char *)&pel,sizeof(pel)); if(z.eof()) break; cout<<"Cądigo: "<