Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<windows.h>
- #include<stdio.h>
- #include<conio.h>
- #include<fstream>
- #include<stdlib.h>
- #include<stdio.h>
- using namespace std;
- class productossolicitados
- {
- private:
- struct prosol
- {
- int CodigoProSol;
- int CantidadProSol;
- char NombreProSol[100];
- char NombresProSol[100];
- }datProSol[100];
- bool encontradoprosol;
- int num_ProSol, iProSol;
- FILE*prosol;
- FILE*faux;
- public:
- void menu_gen();
- void menu_prosol();
- void ingresarprosol();
- void mostrarprosol();
- void actualizarprosol();
- void eliminarprosol();
- }ob_es;
- int main(){
- system("color b");
- ob_es.menu_gen();
- return 0;
- }
- void productossolicitados::menu_gen()
- {
- int opcion3;
- system("cls");
- do{
- cout<<"\n\n"<<"\t\t\t\t\t\t"<<"MENU GENERAL"<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"1 = Productos Solicitados"<<endl;
- //cout<<"2 = Productos recien ingresados a empresa"<<endl;
- //cout<<"3 = Productos vendidos"<<endl;
- //cout<<"4 = Productos solicitados por clientes"<<endl;
- cout<<"\t\t\t\t"<<"2 = Salir"<<endl;
- cout<<"\t\t\t\t"<<"Indique el numero de la opcion que desea: ";
- cin>>opcion3;
- switch(opcion3)
- {
- case 1:
- ob_es.menu_prosol();
- break;
- }
- }while(opcion3 !=2);
- }
- void productossolicitados::menu_prosol()
- {
- int opcion;
- system("cls");
- do{
- cout<<"\n\n"<<"\t\t\t\t\t\t"<<"MENU PRODUCTOS SOLICITADOS"<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"1 = Ingreso de Producto(s) Solicitado(s)"<<endl;
- cout<<"\t\t\t\t"<<"2 = Mostrar Producto(s) Solicitado(s)"<<endl;
- cout<<"\t\t\t\t"<<"3 = Modificar Producto(s) Solicitado (s)"<<endl;
- cout<<"\t\t\t\t"<<"4 = Eliminar Producto(s) Solicitado(s)"<<endl;
- cout<<"\t\t\t\t"<<"5 = Ir al Menu Principal"<<endl;
- cout<<"\t\t\t\t"<<"Indique el numero de la opcion que desea: ";
- cin>>opcion;
- switch(opcion)
- {
- case 1:
- ob_es.ingresarprosol();
- break;
- case 2:
- ob_es.mostrarprosol();
- break;
- case 3:
- ob_es.actualizarprosol();
- break;
- case 4:
- ob_es.eliminarprosol();
- break;
- case 5:
- ob_es.menu_gen();
- break;
- }
- }while( opcion !=5);
- }
- void productossolicitados::ingresarprosol()
- {
- ofstream fprosol;
- fprosol.open("C:/P/fprosol.txt",ios::out|ios::app);
- system("cls");
- cout<<"INGRESO DE DATOS: ";
- if(fprosol.is_open())
- {
- system("cls");
- cout<<"Ingresar Codigo de Producto Solicitado: "<<endl;
- cin>>datProSol[iProSol].CodigoProSol;
- cout<<"Ingresar Nombre de Producto Solicitado: "<<endl;
- cin>>datProSol[iProSol].NombreProSol;
- cout<<"Ingresar Nombre de Solicitante "<<endl;
- cin>>datProSol[iProSol].NombresProSol;
- cout<<"Ingresar Cantidad de Producto Solicitado "<<endl;
- cin>>datProSol[iProSol].CantidadProSol;
- cout<<"________________________________________"<<endl;
- fprosol<<datProSol[iProSol].CodigoProSol<<"\n"<<datProSol[iProSol].NombreProSol<<"\n"<<datProSol[iProSol].NombresProSol<<"\n"<<datProSol[iProSol].CantidadProSol<<"\n\n"<<endl;
- }
- else
- {
- system("cls");
- cout<<"No se ha podido crear el archivo"<<endl;
- getch();
- }
- fprosol.close();
- getch();
- }
- void productossolicitados::mostrarprosol()
- {
- int opcion2;
- system("cls");
- ifstream fprosol;
- fprosol.open("C:/P/fprosol.txt");
- if(fprosol.is_open())
- {
- fprosol>>datProSol[iProSol].CodigoProSol;
- for(iProSol=0; iProSol<25;iProSol++)
- {
- while(!fprosol.eof())
- {
- fprosol>>datProSol[iProSol].NombreProSol>>datProSol[iProSol].NombresProSol>>datProSol[iProSol].CantidadProSol;
- system("cls");
- cout<<"\t\t\t\t"<<"____________________________________________________"<<endl;
- cout<<"\t\t\t\t"<<"Codigo de Producto Solicitado: "<<datProSol[iProSol].CodigoProSol<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"Nombre de Producto Solicitado: "<<datProSol[iProSol].NombreProSol<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"Nombre de Solicitante: "<<datProSol[iProSol].NombresProSol<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"Cantidad de Producto Solicitado "<<datProSol[iProSol].CantidadProSol<<"\n"<<endl;
- cout<<"\t\t\t\t"<<"____________________________________________________"<<endl;
- fprosol>>datProSol[iProSol].CodigoProSol;
- getch();
- }
- }
- }
- else
- {
- system("cls");
- cout<<"ERROR! No se ha podido abrir el archivo o no se encontraron registros!";
- getch();
- }
- fprosol.close();
- getch();
- }
- void productossolicitados::actualizarprosol()
- {
- ofstream faux;
- ifstream fprosol;
- int codprosol_aux, cantidadprosol_aux;
- encontradoprosol=false;
- char nombprosol_aux,nombrsprosol_aux;
- faux.open("C:/P/fprosol_auxiliar.txt",ios::in);
- fprosol.open("C:/P/fprosol.txt");
- if(faux.is_open() && fprosol.is_open())
- {
- cout<<"Ingresar codigo de Producto Solicitado que desea actualizar: "<<endl;
- cin>>codprosol_aux;
- fprosol>>codprosol_aux;
- fprosol>>datProSol[iProSol].CodigoProSol;
- while(!fprosol.eof())
- {
- fprosol>>datProSol[iProSol].NombreProSol>>datProSol[iProSol].NombresProSol>>datProSol[iProSol].CantidadProSol;
- if(codprosol_aux==datProSol[iProSol].CodigoProSol)
- {
- encontradoprosol=true;
- cout<<"Codigo de Producto Solicitado: "<<datProSol[iProSol].CodigoProSol<<"\n"<<endl;
- cout<<"Nombre de Producto Solicitado: "<<datProSol[iProSol].NombreProSol<<"\n"<<endl;
- cout<<"Nombre Solicitante: "<<datProSol[iProSol].NombresProSol<<"\n"<<endl;
- cout<<"Cantidad de Producto Solicitado: "<<datProSol[iProSol].CantidadProSol<<"\n"<<endl;
- cout<<"________________________________________"<<endl;
- cout<<"Ingresar nuevo Nombre de Producto Solicitado: "<<endl;
- cin>>nombprosol_aux;
- cout<<"Ingresar nuevo Nombre de Solicitante: "<<endl;
- cin>>nombrsprosol_aux;
- cout<<"Ingresar nueva Cantidad de Producto: "<<endl;
- cin>>cantidadprosol_aux;
- getch();
- faux<<datProSol[iProSol].CodigoProSol<<"\n"<<nombprosol_aux<<"\n"<<nombrsprosol_aux<<"\n"<<cantidadprosol_aux<<"\n"<<endl;
- cout<<"Se ha completado la actualizacion de los datos con exito!"<<endl;
- }
- else{
- faux<<datProSol[iProSol].CodigoProSol<<" "<<datProSol[iProSol].NombreProSol<<" "<<datProSol[iProSol].NombresProSol<<" "<<datProSol[iProSol].CantidadProSol<<" "<<endl;
- }
- }
- }
- fprosol.close();
- faux.close();
- remove("C:/P/fprosol.txt");
- rename("C:/P/fprosol_auxiliar.txt","C:/P/fprosol.txt");
- }
- void productossolicitados::eliminarprosol()
- {
- ifstream fprosol;
- ofstream faux;
- int codprosol_aux2;
- fprosol.open("C:/P/fprosol.txt",ios::in);
- faux.open("C:/P/fprosol_auxiliar.txt",ios::out);
- if(faux.is_open() && fprosol.is_open())
- {
- cout<<"______________________________________________________"<<endl;
- cout<<"Ingresar codigo de Producto Solicitado que desea eliminar: "<<endl;
- cin>>codprosol_aux2;
- fprosol>>datProSol[iProSol].CodigoProSol;
- while(!fprosol.eof())
- {
- fprosol>>datProSol[iProSol].NombreProSol>>datProSol[iProSol].NombresProSol>>datProSol[iProSol].CantidadProSol;
- if(codprosol_aux2==datProSol[iProSol].CodigoProSol)
- {
- cout<<"Se ha completado la eliminacion de los datos con exito!"<<endl;
- }
- else{
- faux<<datProSol[iProSol].CodigoProSol<<"\n"<<datProSol[iProSol].NombreProSol<<"\n"<<datProSol[iProSol].NombresProSol<<"\n"<<datProSol[iProSol].CantidadProSol<<"\n"<<endl;
- }
- }
- }
- fprosol.close();
- faux.close();
- remove("C:/P/fprosol.txt");
- rename("C:/P/fprosol_auxiliar.txt","C:/P/fprosol.txt");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement