#include<cstdlib> #include <iostream>
using namespace std; struct factura{ int fecha; struct fecha{ int dia; int mes; int anio; }d; struct cliente{ string nombre; string direccion; string telefono; string producto[3][4]; }c; }f; int cont=0; void cargar(factura &F){ int i=0, j=0, sel=0; string descrip[6]={"CODIGO: ", "NOMBRE: ", "DESCRIPCION: ", "PRECIO: $ " }; cout<<"REGISTRE LOS SIGUENTES DATOS PARA GENERAR LA FACTURA"<<endl; cout<<"FECHA "<<endl; cout<<"ELIJA UNA OPCION "<<endl; cout<<" *1: FECHA ACTUAL"<<endl; cout<<" *2: OTRA FECHA"<<endl; cout<<"LA OPCION ES: "; cin>>sel; switch(sel){ case 1: time_t t; struct tm *ahora; time(&t); ahora = localtime(&t); printf("LA FECHA ACTUAL ES: %02d/%02d/%02d ",ahora->tm_mday, ahora->tm_mon + 1, ahora->tm_year + 1900); cout<<endl; f.d.dia=ahora->tm_mday; f.d.mes=ahora->tm_mon + 1; f.d.anio=ahora->tm_year + 1900; cout<<"DIA : "<<f.d.dia<<endl; cout<<"MES : "<<f.d.mes<<endl; cout<<"ANIO: "<<f.d.anio<<endl<<endl; cout<<"DATOS DEL CLIENTE"<<endl; fflush(stdin); cout<<"NOMBRE: "; getline(cin,f.c.nombre); fflush(stdin); cout<<"DIRECCION: "; getline(cin,f.c.direccion); fflush(stdin); cout<<"TELEFONO: "; getline(cin,f.c.telefono); fflush(stdin); cout<<endl; cout<<"DATOS DEL PRODUCTO"<<endl; fflush(stdin); for(i=0;i<3;i++){ for(j=0;j<4;j++){ cout<<descrip[j]; cin>>f.c.producto[i][j]; } cout<<endl; } system("cls"); break; case 2: cout<<"DIA: "; cin>>f.d.dia; while(f.d.dia>31){ cout<<"DIA NO VALIDO"<<endl; cout<<"DIA: "; cin>>f.d.dia; } cout<<"MES: "; cin>>f.d.mes; while(f.d.mes>12){ cout<<"MES NO VALIDO"<<endl; cout<<"MES: "; cin>>f.d.mes; } cout<<"ANIO: "; cin>>f.d.anio; while(f.d.anio<1000){ cout<<"ANIO NO VALIDO"<<endl; cout<<"ANIO: "; cin>>f.d.anio; } system("cls"); cout<<"DATOS DEL CLIENTE"<<endl; fflush(stdin); cout<<"NOMBRE "; getline(cin,f.c.nombre); fflush(stdin); cout<<"DIRECCION "; getline(cin,f.c.direccion); fflush(stdin); cout<<"TELEFONO "; getline(cin,f.c.telefono); fflush(stdin); system("cls"); cout<<"DATOS DEL PRODUCTO"<<endl; fflush(stdin); for(i=0;i<3;i++){ for(j=0;j<4;j++){ cout<<descrip[j]; getline(cin,f.c.producto[i][j]); } cout<<endl; } system("cls"); break; default: cout<<"OPCION NO DISPONIBLE"<<endl; } } void imprimir(factura &F){ int i, j; string descrip[6]={"CODIGO ", " NOMBRE ", " DESCRIPCION ", " PRECIO " }; if(cont==1){ cout<<"DIA : "<<f.d.dia<<" MES : "<<f.d.mes<<" ANIO: "<<f.d.anio<<endl<<endl; cout<<"NOMBRE: "<<f.c.nombre<<endl;; cout<<"DIRECCION: "<<f.c.direccion<<endl; cout<<"TELEFONO: "<<f.c.telefono<<endl; cout<<endl; for(i=0;i<4;i++){ cout<<descrip[i]; } cout<<endl; for(i=0;i<3;i++){ for(j=0;j<4;j++){ cout<<f.c.producto[i][j]<<" "; } cout<<endl; } cout<<endl; } else{ cout<<"LA FACTURA NO SE HA CARGADO"<<endl; } }
int main(){ factura F; int sel; system("color 1f"); do{ system("color 3f"); cout<<"/////////////////////////////////////////////"<<endl; cout<<"* /"<<endl; cout<<"* BIENVENIDO AL MENU DE FACTURACION /"<<endl; cout<<"* /"<<endl; cout<<"* 1: INGRESAR DATOS /"<<endl; cout<<"* 2: IMPRIMIR /"<<endl; cout<<"* 3: SALIR /"<<endl; cout<<"* /"<<endl; cout<<"* * * * * * * * * * * * * * * * * * * * * * *"<<endl; cout<<endl; cout<<"LA OPCION ES: "; cin>>sel; system("cls"); switch(sel){ case 1: cont=1; cargar(F); break; case 2: imprimir(F); break; default: cout<<"OPCION NO DISPONIBLE"<<endl; } }while (sel!=3); }
|