Professional Documents
Culture Documents
INFORME PARTE B
Gestin de Inmobiliaria
Integrantes:
Juan Pablo Espinosa Lara Ivn Alejandro Moya Quilodrn Fecha: 19/11/2012
1 Tabla de contenido
2 3 Introduccin ......................................................................................................................... 1 Anlisis ................................................................................................................................. 2 3.1 Estructuras .................................................................................................................... 2 Struct cliente .......................................................................................................... 2 struct encamp ......................................................................................................... 3 struct departamento............................................................................................... 4 struct edificio ......................................................................................................... 4 Struct condominio ................................................................................................. 5 Struct provincia: .................................................................................................... 6 Struct regiones ....................................................................................................... 7 Struct sistema......................................................................................................... 7 Struct ventas .......................................................................................................... 8 Struct pila.............................................................................................................. 8
3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.1.10 4
............................................................................................................................................... 10 4.2 Funciones .................................................................................................................... 11 Cargar informacin .............................................................................................. 11 Funciones agregar ................................................................................................ 15 Funciones eliminar .............................................................................................. 18 Funciones modificar ........................................................................................... 22 Funciones listar .................................................................................................... 23 Funciones actualizar informacin en ficheros ..................................................... 23 Funcion buscar cliente ........................................................................................ 24 Menus y sub menus . ........................................................................................... 27
4.3.1
............................................................................................................................................ 29
i
4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.3.10 4.4
Funcion MenCompleto ..................................................................................... 30 Men Administrador .......................................................................................... 31 Men Vendedor ................................................................................................... 32 Men Eliminar ..................................................................................................... 33 Modificar Edificio ............................................................................................... 34 Listar Edificio ...................................................................................................... 35 Vender Departamento .......................................................................................... 37 Eliminar Cliente.................................................................................................. 38 Actualizar............................................................................................................. 39
Interfaz grafica ............................................................................................................ 40 Ventana principal ................................................................................................. 40 Menu condominio ................................................................................................ 40 Agregar condominio ............................................................................................ 41 Menu vendedor .................................................................................................... 41 Listar clientes ....................................................................................................... 42 Vender departamento ........................................................................................... 42
Desarrollo de las Actividades del proyecto. ............................................................... 43 Carta Gantt (grupal). ............................................................................................ 43 Carta Gantt (Ivan Moya)...................................................................................... 43 Carta Gantt (juan pablo) ...................................................................................... 43
ii
2 Introduccin
.La gestin de ventas de una inmobiliaria se hace bastante tediosa y engorrosa si no se aplican las diferentes formas y mtodos de trabajar la informacin con esto nos damos cuenta que con la tecnologa que contamos y el hacer un buen uso de esta puede transformar de manera significativa la forma de poder gestionar la informacin con la que se cuenta haciendo mas confiable eficaz y eficiente ciertas tareas tales como la venta de departamentos y el manejo de los clientes
Es por eso que como informticos se nos ha pedido un modelamiento para el buen manejo de la informacin de esta compaa y para ello utilizaremos todos los conocimientos necesarios ya sea que los tengamos o no para poder as dar un sistema para una buena gestios de ventas lo uqe conlleva el manejo de departamentos por edificio y estos a la vez por condominio y estos por ubicacin territorial(regin,provincia)
3 Anlisis
Para un buen y fcil manejo del a informacin hemos utilizado 8 estructuras diferentes las cuales corresponden a 1 lista contigua 2 estructuras que solo guardan informacin en la que una de ellas es una matriz 2 listas doblemente enlazadas la cual una de ellas encapsula la informacin referente a los clientes para un mejor manejo de estos 2 listas simplemente enlazadas una estructura que contiene la totalidad de la informacin del programa una estructura compleja que corresponde a un rbol mas una lista enlazada la cual es una pila que se usara para el manejo de la informacin dentro del rbol y una ultimo lista simplemente enlazada la cual es una lista que contiene las ventas realizadas
3.1 Estructuras
Son 10 estructuras, como se dijo anteriormente, llamadas Strcut ventas Struct pila Struct cliente Struct encamp Struct departamento Struct edificio Struct condominio Struct provincial Struct regiones Struct sistema
Esta estructura contiene la informacin necesaria de los clientes tales como el nombre del cliente el telfono asi como su rut , una id (proporsionada por el programa para hascer asi aun mas fcil su bsqueda dentro de este ),regin y provincia Char * nombre = contiene el nombre Int fono =contiene el telfono del cliente Char rut = contiene el rut del cliente Int id = contiene un id generada por el programa siendo nica para cada cliente Int regin = contiene la regin del cliente Int provincia = contiene la provincia del cliente
Contiene los datos del departamento esta estructura a la vez se encuentra anidada en una matriz
int estado]=contiene el estado del departamento que corresponde a vendido o no segn contenga un 1 o un 0 int numeroDepa = guarda el numero del departamento .
struct cliente= corresponde a un puntero a la lista clientes donde apunta al cliente asociado al departamento el cual es quien lo compro
Contiene los datos de cada edificio . corresponde a una lista simplemente enlazada anidada dentro de la lista doble condominios
char * nombre_edificio= En esta variable va el nombre del edificio o como se conoce normalmente torre. ,2,3 Int tipo = correspode al tipo de departamento que contiene este edificio . Int opcin= contiene la opcin de departamento que es pusiendo ser del tipo 1
Struct departamento ***tipos_departamentos= es una matriz que contiene a los departamentos Struct cliente **clien= la direccin de memoria a la lista de clientes para llevar un mejor manejo de estos y solo los asociados al edificio Struct edificio *sig= es un puntero al prximo nodo de esta lista simple
Char * nombre_condominio=contiene el nombre del condominio Char*caractersticas_condominio= una pequea resea del condominio Int numero edificios= contiene la cantidad de edificios que tiene el condominio
Int id= contiene una id generada para diferenciar a cada condominio para poder ser asi ordenada en el arbol
5
Int stock=contiene el numero de condominios que estn disponibles para la venta Int opcin=contiene un numero para poder ser usado luego en el programa casi como un numero identificador Struct condominio *izq,*der=dos punteros el cual uno apunta a la derecha y otro a la izquierda ya que se trata de un rbol Struct edificio *edi= puntero apuntando al a lista de edificios que contiene el condominio
Int identificador= es un numero identificador el cual le asignamos a cada provincia para tener un mejor manejo de estos Int opcin= tambin por preguntar al ivan
Struct provincia*sig= variable puntero apuntando al nodo siguiente ya que se trata de una lista simplemente enlazada Struct condominio *condom=puntero apuntando a una lista de condominios asociados a la provincia
Char * nombre= contiene el nombre de la regin Int numero= contiene un numero asociado a la regin Struct provincia= necesario este puntero ya que se trata de una lista contigua.
Struct ventas *caeza=puntero a una lista simplemente enlazada que contiene las ventas realizadas por los clientes
Int cuotas pagadas = entero que contiene el numero de cuotas que se llevan pagadas de esa venta Int total = entero que contiene la cantidad total a pagar por esa venta
Struct ventas *sig= puntero que apunta al siguiente nodo ya uqe se trata de una lista simplemente enlazada.
Struct condominio *valor=puntero que apunta a un nodo del rbol ya uqe esta pila se usa para rescatar los valores del arbol Struct pila *sig = puntero que apunta al nodo siguiente de la pila
4 Diseo
4.1 Estructura del programa
En este programa utilizaremos un nodo que encerrara por completo a todas las estructuras usadas en el programa este nodo tendra tres punteros primero un puntero a una lista contigua de largo 15 el cual cada posicin de la lista contigua tendr anidada una lista simplemente enlazada de provincias que sern en total 56 nodos los cuales sern agrupadas en listas segn a la regin que pertenezcan a la vez cada nodo de provincia contiene una estructura compleja que en este caso ser un arbol de condominios el cual tendr una lista simple con los edificios de estos que a la vez dentro del nodo edificio existir una matriz representando a los departamentos Para el segundo puntero que contiene el nodo sistema que es el nodo descrito anteriormente que contiene a todas las estructuras este puntero apunta a una lista simplemente enlazada que encapsulara a otra lista que corresponde a la de clientes los cuales tambin sern apuntados por la matriz de departamentos Y para el tercer puntero ser apuntado a una lista simplemente enlazada la cual contiene todas las ventas realizadas A continuacin se comienza a describir lo antes dicho mediante un gran diagrama para poder aclarar las dudas
regiones
fgfg
Lista provincias
Lista vent as
Arbol condomini os
10
Diagrama Modelo De La Informacion Y Estructuras
4.2 Funciones
Son 87 funciones en total, las cuales cumple las siguientes tareas: 4.2.1 Cargar informacin 4.2.1.1 void Comenzar( struct Sistema *Cabecera, struct Encamp **inicioCliente) En esta funcin se le envan todos los datos del sistema que seria la cabezera de todo el sistema y crea la listacontigua de regiones las cuales es esttica tambin se le enva la cabezera que encapsulara a la lista de clientes y con esta tambin se genera la lista de clientes . 4.2.1.2 struct regiones * crearArreglo(char buffer[] ,int numregion, char ruta[],int *identificador) En esta funcin se manda un char con el nombre de la regin , un int que es el numero de la regin ,otro char que corresponde a la ruta del archivo de texto que contiene los datos necesarios de cada regin ,y un int que es un numero identificador que le daremos a cada provincia de cada regin. Al ser una funcin de tipo struct regiones devuelve una casilla de la lista contigua 4.2.1.3 char*rutaidentregiones(int) Esta funcion recibe un entero con el numero de la regin se encarga de pasar este numero a char para que la siguiente funcion tenga su ruta donde se encuentra la cantidad de condominios que tiene esa regin 4.2.1.4 int * vectorident(char *ident) En esta funcion se recibe una char con el numero de la regin y se toma este char como la ruta de un archivo de texto donde se encuentran los condominios de tiene dicha regin y retorna el numero de condominios
11
4.2.1.9 void agregarcondominioarbol(struct condominio **raiz, int valor,char *rutaCondo, int Opcion, int *cont).
Esta funcion recibe la raz del rbol ,un entero valor que es el numero identificador del condominio un char con la ruta de donde esta el condominio un entero con el numero identificador que se le da y un entero contador su funcion es agregar los condominios al rbol ordenados segn el numero identificador de cada condominio 4.2.1.10 void RecorrerArbolParaDepa (struct condominio *raiz, int *cuenta_stock). Recibe la raz del rbol y un entero con el stock de departamentos que contendr el condominio recorre el rbol para poder crear los departamentos utilizando las funciones push y pop respectivamente
12
4.2.1.13 struct edificio * CrearDepa (int numeroEdi, char *NomCondominio, int *stock)
Esta funcin es llamada por la funcin struct condominio * ComprobarCondominios al kigual que las dos funciones anteriores . Se recibe un in con el numero de edificios por condominio un char con el nombre del condominio al cual pertenecern los edificios y un int pasado por parmetros para llevar el buen manejo del stock de los departamentos de cada edificio de todos los condominios esta funcin al ser un struct edificio retorna un nodo para la lista de edificios del condominio que le corresponde .
4.2.1.19 struct departamento *** ConstruirDepa (int tipo, FILE *DEPA, int *stock);
Esta funcin recibe un int que contiene el tipo de departamento que sera ,recibe el puntero que abri el archivo en la funcin anterior crea los departamentos dentro de el archivo de texto de forma ordenada casi como se ve grficamente los departamentos enumerndolos segn el piso en el que se encuentren tambin copia una lista de los clientes asociados a dichos departamentos para llevar un mejor manejo de estos .
tarea recorre y enva la lista de edificios a la funcin crearEncap donde se implementara el encapsulamiento.
15
Esta funcin es llamada por la funcin anterior creardepasolo , recibe un struct edificio *nodo llenar y un int que esta la cuenta de stock su funcin es llenar el nodo del edificio del condominio
Esta funcin es llamada por la funcin anterior llenardatosedi , recibe un puntero a el archivo donde se guardaran los estados de los departamentos y el puntero a edificios la funxion principal de esta funcin es poner el estados de no vendido en el archivo de texto
16
4.2.2.15 Struct cliente * BuscarDepa(struct edificio *inicioEdi, int Region, int Provin)
Esta funcin recibe dos punteros uno a la lista de edificios y dos enteros que seria el numero de la regin y otro con el numero de la provincia dodne se desea comprar el departamento y su funcion es ir listando los condominios y edificios para que se elija uno el cual ser vendido.
4.2.2.16 Struct cliente * MostrarDisponibles (struct edificio *edi, int Region, int Provin)
Esta funcin recibe dos punteros uno a la lista de edificios y dos enteros que seria el numero de la regin y otro con el numero de la provincia su funcin principal es mostrar solo los departamentos disponible para la venta y su seleccin para realizar la venta .
4.2.2.17 Int coprobarDepa(struct edificio *edi,int fila,int columna,int NumDepa,int *filaOcupada, int *columnaOcupada)
Esta funcin recibe el puntero al edificio que contiene el departamento a comprar dos int con la fila y columna del departamento dentro del fichero de texto y dos int mas que son los que se quieren corroborar adems de un int con el numero del departamento a comprar su tarea principal comprueba con el archivo de texto si la opcin entregada es correcta ,ve si esta o no ocupado el departamento que se quiere comprar .
17
4.2.2.18 struct cliente * CrearNuevoCliente (int NumDepa, int Region, int Provin)
Esta funcin llena los datos del cliente que compro el departamento y retorna el nodo
4.2.2.20 void copiarIdFichero (int id, struct edificio *Edi, int fila, int columna)
Esta funcion guarda en el archivo de texto de clientes al nuevo cliente para respaldar la informacin
condominio luego lista la lista de condominios para que se ingrese la opcin del condominio que se quiere eliminar .
4.2.3.8 int EliminarEdificio(struct edificio **inicio, struct edificio *Eliminar, struct condominio *condo)
Esta funcin recibe el inicio de la lista de edificios de un condominio tambin el edificio a eliminar y la direccin de memoria de este para poder modificarlo y con ellos desenlaza a este y lo elimina de la lista.
19
20
4.2.3.17 int borraCliente(struct edificio *edi,int fila, int columna, struct cliente *Encontrado)
Esta funcion recibe el edificio donde se encuentra el departamento del cliente a eliminar tambin se recibe fila columna que son las cordenadas del departamento del cliente para tener la ubicacin en el archivo de texto y por ultimo se recibe el cliente a eliminar esta funcion se encarga de borrar al cliente deseado
21
23
24
4.2.7.7 struct departamento * RecorridoDepa(struct edificio *edificioEncontrado,int fila,int columna,struct cliente *Encontrado)
Esta funcion recibe el edificio en el cual se encuentra el departamento del cliente encontrado tambin al cliente encontrado y la fila y columna que son coordenadas para poder buscar el numero del departamento comprado por el cliente encontrado la tarea principal de esta funcin es dar a conocer el numero del departamento comprado por el cliente encontrado
25
4.2.7.8 void actualizar_ventas(struct Sistema *head) Esta funcion rescive a head y se encarga de actualizar el fichero que contiene la informacin refente a la lista de ventas la cual tiene la id del cliente el monto total de la venta y cuantas cuotas tiene pagada hasta el momento
26
esta funcion se encarga de eliminar un nodo del rbol que corresponde a eliminar un condominio y para ello recibe un entero con el numero identificador que se le dio a ada condominio para odenarlo dentro del rbol y para su ubicacin ya que ese numero es nico.
27
28
Inicio
Comenzar (Cabecera,&inicioCliente);
Cabecera->EncapCliente=inicioCliente;
Fin
29
while (esta==0) si
printf("\n\t**ingrese tipo de usuario**\n ) printf(\t**1) administrador **\n) printf(\t**2) vendedor ** \n ") scanf("%d",&opadmono)
while(opadmono>2 || opadmono<1)
si
no actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n REALMENTE DESESAS SALIR 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta);
no
switch (opadmono) si
no if(esta!=0) si
case 1:
si
while(claveadm!=12345) si
no no
esta=1
menuadmin(tmp);
si
Fin
case 2:
menuvendedor(tmp);
30
Inicio
while(esta==0)
printf("** 1) Condominio **\n") printf("** 2) Edificio **\n") printf("** 3) Cliente **\n") printf("** 4) Salir **\n") scanf("%d",&Opcion)
while(opcionadm>4&&op cionadm<1) no
si
printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => ) scanf("%d",&esta);
switch (Opcion) si
si MenuCondominio(head)
si case 2: MenuEdificio(head)
Fin
no si case 3: MenuClientes(head)
no si case 4 : no return
Diagramas 3MenuAdimistrador
31
printf("** 1) Vender Departamento **\n") printf("** 2) Listar Clientes **\n") printf("** 3) Buscar Cliente **\n") printf("** 4) Salir **\n") scanf("%d",&OpcionCli)
while(OpcionCli>4 &&OpcionCli<1)
si
no
Inicio
switch(OpcionCli)
no
case 1:
si
respuesta = VenderDepa(head>totalregiones,&nuevoCliente)
si
no
esta=1;
case 3:
si
crearEncap(&head>EncapCliente,nuevoCliente)
no
Fin
case 4: si
if(!encontrado)
si
puts("CLIENTE NO ENCONTRADO")
return
Diagram 4 MenuVendedor
32
Inicio
Region=buscar _prov(head)
provin = head>totalregiones[Region]->prov
CondoEscojido = BuscarCondo(provin,&ident);
if(CondoEscojido)
si
Edi = BuscarEdifi(CondoEscojido)
return 0
if(Edi)
si
no
Fin
no
return 0
Diagram 6 MenuEliminar
33
Inicio
Region=buscar _prov(head)
provin = head>totalregiones[Region]->prov
CondoEscojido = BuscarCondo(provin,&ident);
if(CondoEscojido)
si
Edi = BuscarEdifi(CondoEscojido)
return 0
if(Edi)
si
no
Fin
return 0
return ModificarEdi
34
Inicio
Region=buscar _prov(head)
provin = head>totalregiones[Region]->prov
CondoEscojido = BuscarCondo(provin,&ident);
if(CondoEscojido)
si
Edi = BuscarEdifi(CondoEscojido)
no if(Edi) si MostarEdi(Edi)
return 0
no
Fin
Diagram 8 Listar Edificio
return 0
35
36
Fin
while(respuesta==0)
si
while (esta3==0)
si
no printf(" %d ) = %s \ n",totalregiones[i]>numero,totalregiones[i]>nombre)
si
no
si
esta3=1 si
DepaEscojido = BuscarEdifi(CondoEscojido)
si
if(nuevoCliente)
si
no while (esta2==0)
no
return 1;
no
return 1
37
Inicio
puts("BUSQUEDA DE CLLIENTES MEDIANTE POR : "); puts("1 = NOMBRE )" puts("2 = ID ") puts("3 = RUT") puts("4 = SALIR") scanf("%d",&Opcion);
while(esta==0) no
si
no
switch (Opcion)
if(Encontrado)
si
esta=1
case 1:
si
return Encontrado
case 2:
si
Fin
case 3: no
si
38
4.3.10 Actualizar
Diagramas 15 Actualizar
Inicio
CONDO = fopen("CONDOS.txt","w")
if(!CONDO)
si
no
Fin
fclose(CONDO)
return 1
no
for(i=0;i<15;i++)
si
nuevo1 = totalregiones[i]>prov
nuevo1=nuevo1->sig
no
while(nuevo1 !=NULL)
si
nuevo2=nuevo1>condom
if(!(nuevo2))
si
nuevo1=nuevo1>sig
no
if(!CONDO)
39
40
Ilustracion 3 AgregarCondominio
41
42
43
5 Conclusin
En este trabajo nos dimos cuenta lo difcil que es el manejo de datos y lo fcil que lo hace el manejo de estructuras para su buen manejo y eficacia tambin se puede destacar que por ser primerizoz en esto de desarrollo de programas mas avanzados este proyecto fue de gran ayuda para comprender y aprender bsicamente todos los elementos necesarios para el desarrollo de los grandes programa que conocemos siendo haci este proyecto una gran oportunidad para adquirir una pequea pisca de experiencia para lo que se nos vendr mucho mas adelante cabe destacar que quedaron muchas dudas al respecto y asi demasiadas cosas que se utilizaron en este proyecto no se tuvieron la total comprensin y solo se usaron por el solo hecho que asi funcionaba tambin destacar lo autodidacta que fue nos dio un gran conocimiento que utilizaremos en unos aos mas que consiste en tener que buscar uno mismo las respuestas a las interrogantes sobre la materia que no se paso en clases tal como fue la interfaz
44
6 Anexo
6.1.1 Codigo fuente
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<time.h>
struct ventas{ int idclie; int cuotaspagadas; int total; struct ventas *sig; }; struct pila { struct condominio *valor ; struct pila *sig ; }; 45
struct cliente { char *nombre; int fono; char *rut; int id; int region; int provincia; };
struct departamento{ int estado; int numeroDepa; char *caracteristicas; struct cliente *clie; };
struct departamento ***tipos_departamentos; struct cliente **clien; int ultimo; struct edificio *sig; };
struct condominio{ char* nombre_condominio; char* caracteristicas_condominio; char numero_edificios; int id; int stock ; int opcion; struct condominio *izq,*der; struct edificio *edi; };
struct provincia { char* nombre; int identificador; int opcion; struct provincia *sig; struct condominio *condom; };
struct regiones{ 47
struct Sistema{ char * Nombre; struct regiones *totalregiones[15]; struct Encamp *EncapCliente; struct ventas *caeza; };
void Comenzar (struct Sistema *,struct Encamp **); struct regiones * crearArreglo(char *,int, char[]); struct provincia * cargarProvi(char *, int*); struct condominio * ComprobarCondominios(int, int *,char *); void CrearCondo (struct condominio **); void Copiardatos(struct condominio *,char *, int, int *); char * ruta2(int); char * CrearRuta (char *); struct edificio * CrearDepa(int, char *, int*); void CargarEdi (struct edificio * , char *, int *); int actualizar (struct regiones **); int ContarCondominios (struct condominio *); void actualizarCondominios(struct condominio *, int); void actualizarDepa(struct condominio *); 48
char * CrearRutaDepa (char *); void ArmarDepartamentos (struct edificio *inicio, int *); struct departamento *** ConstruirDepa(int,FILE *, int *); void EncontrarClientes(struct edificio *, int); int DepaporTipo (int, int *, int *); void AgregarClientes (struct provincia *,struct Encamp **); void clienteDepa(struct condominio *,struct Encamp **); void crearEncap ( struct Encamp **, struct cliente *); struct cliente * CopiarClientes (int); int GeneradorId (); /////////////////////////////////////// funciones para clientes//////////////////////////////// int VenderDepa(struct regiones **, struct cliente **,struct Sistema *); struct edificio * BuscarEdifi (struct condominio *); struct condominio * BuscarCondo(struct provincia *inicio, int *); struct cliente * BuscarDepa(struct edificio *inicioEdi, int ,int,struct Sistema *); struct cliente * MostrarDisponibles (struct edificio *, int, int,struct Sistema * ); int coprobarDepa(struct edificio *,int,int,int,int *, int *); struct cliente * CrearNuevoCliente (int , int , int,int ,struct Sistema **); void AgregarEncapClientes (struct Encamp ** , struct cliente *); void ListarClientes (struct Encamp *); struct cliente * BuscarCliente (struct Sistema *); struct cliente * BusquedaClienteNom(struct Encamp *); void Opciones (struct cliente *, struct Sistema *); void mostrarProvincia (struct cliente *, struct regiones **); void mostarDepa(struct cliente *,struct regiones **); struct condominio * RecorridoCondo(struct edificio *, struct cliente *, struct condominio *); 49
struct departamento * RecorridoDepa(struct edificio *,int ,int ,struct cliente *); struct edificio * RecorridoEdi(struct condominio *, struct cliente *); struct cliente * BusquedaClienteId(struct Encamp *); struct cliente * BusquedaClienteRut(struct Encamp *); void mostrarCondominio(struct cliente *,struct regiones **); struct provincia * BuscarProvin(struct provincia *, int); int borraCliente(struct edificio *,int , int , struct cliente *); void Compactar(struct edificio *); struct cliente * EliminarCliente (struct Sistema *); void QuitarenLista(struct edificio *,struct cliente *); void actualizarCliente (struct Encamp *); void copiarIdFichero (int , struct edificio *, int , int ); void SacarClienteFichero (struct edificio *,int,int ); int EliminarEncapCliente(struct Encamp **, struct cliente *); ///////////////////////////menu void MenuClientes(struct Sistema *); void MenuCondominio (struct Sistema *); void MenuEdificio(struct Sistema *); void menuvendedor(struct Sistema *); /////////////////////// condominio int elimCondo ( struct provincia *); int EliminarCondo(struct Sistema *); int EliminadoCondominio(struct condominio *, struct provincia *); void SacarCondoFichero (struct condominio *); void SacarFicherCondo(int); int AgregarCondominio(struct Sistema *); 50
int AgregarEdificio(struct Sistema *); void ListarCondominios (struct Sistema *); struct condominio * BuscarCondoModificar(struct condominio *); int DatosModificar(struct condominio *); int ModificarCondominio(struct condominio *,struct condominio *); //////edificio void MostarEdi(struct edificio *); void ListarEdificio (struct Sistema *); int ElimiEdificio (struct Sistema *); struct edificio * CrearDepaSolos(int,int *); void llenarDatosEdi(struct edificio *, int *); void PonerEstadoDepa (FILE *, struct edificio *); int contarEdificio(struct edificio *); struct edificio * BuscarEliminarEdi(struct edificio *); int ModificarEdi(struct edificio *,struct edificio *); void CargarClienteEdi (struct edificio *, char *); void menuadmin(struct Sistema *); struct condominio *llenar_dato_condo(); struct provincia * busqueda_ubicacioncondo_aeliminar(struct regiones **totalregiones,int numeroregion,char *nombre_provincia); int eliminar_condo(struct condominio **,char *); int modificar_dato_condo(struct condominio **condo); int buscar_prov(struct Sistema *head); void menucompleto(struct Sistema *); /////////// nuevas ////////// char * RutaIdentCondo(int); 51
void agregarcondominioarbol(struct condominio **, int , char *, int ,int *); struct condominio * eliminarcondominio(struct condominio **, int ); int AgregarEdificioNuevo(struct edificio **, struct condominio * ); char * RutaIdentRgiones(int) ; int * VectorIdent(char *) ; void mostrarCondoArbol(struct condominio *) ; int AgregarNuevoarbol(struct condominio **, struct condominio *, int ); int EliminarCondoArbol(struct condominio **, int ); struct condominio * ComprobarOpcionCondo(struct condominio *,int); void Mostrarinorden(struct condominio *); void RecorridoContarCondo(struct condominio *arbol, int *contador) ; struct condominio * pop (struct pila **) ; struct condominio * preorden(struct condominio *,struct cliente *) ; void RecorrerArbolParaDepa (struct condominio *, int *) ; void push (struct pila **, struct condominio *) ; int * GuardarVectorRegiones (struct regiones **totalesregiones, int *max) ; char * RutaRegionNueva (int RegionNueva) ; char * NomRegion (int RegionNueva) ; void AgregarRegion(struct Sistema* Cabecera) ; void MostrarRegionFalta (int numRegion, int num) ; int eshoja (struct condominio *raiz) ; int ModificarEdificio(struct Sistema *head) ; //funciones extraass struct condominio *recorridocondominio(struct condominio *arbol,struct condominio **); struct condominio *recorridoprovincia(struct provincia *prov); struct condominio *recorridoregion(struct regiones *region); 52
void depamasvendido(struct Sistema *cabezera); void actualizar_ventas(struct Sistema *head); void cargar_datos_venta(struct Sistema *head);//6 void informacion_cliente(struct Sistema *head);//7 int ModificarCondo(struct Sistema *head);
main() { struct Sistema *Cabecera=NULL; struct Encamp *inicioCliente=NULL; int i,actual, opcion, respuesta;
menucompleto(Cabecera);
void Comenzar( struct Sistema *Cabecera, struct Encamp **inicioCliente) { int i, identificador=1, x = 0; FILE *REGIONES ;
53
REGIONES = fopen("Regiones_Condominios.txt","r") ; if(!REGIONES) { printf("NO SE ENCONTRO EL ARCHIVO 2525"); exit(0); } else { while(!feof(REGIONES)) { fscanf(REGIONES,"%d\n",&Cabecera->totalregiones[x]->numero); x++; } fclose(REGIONES); }
for(i=0;i<15;i++){
switch ((Cabecera->totalregiones[i]->numero)-1){
54
case (-2): break ; case 0: Cabecera->totalregiones[i]=crearArreglo("ARICA Y PARINACOTA",Cabecera->totalregiones[i]>numero,"Regiones\\ARICA_Y_PARINACOTA.txt"); break; case 1: Cabecera->totalregiones[i]=crearArreglo("TARAPACA",Cabecera->totalregiones[i]>numero,"Regiones\\TARAPACA.txt"); break; case 2:
Cabecera->totalregiones[i]=crearArreglo("VALPARAISO",Cabecera->totalregiones[i]>numero,"Regiones\\VALPARAISO.txt"); 55
break; case 6: Cabecera->totalregiones[i]=crearArreglo("LIBERTADOR GRAL. BERNARDO O'HIGGINS",Cabecera->totalregiones[i]>numero,"Regiones\\LIBERTADOR_GRAL._BERNARDO_O'HIGGINS.txt"); break; case 7: Cabecera->totalregiones[i]=crearArreglo("MAULE",Cabecera->totalregiones[i]>numero,"Regiones\\MAULE.txt"); break; case 8: Cabecera->totalregiones[i]=crearArreglo("BIOBIO",Cabecera->totalregiones[i]>numero,"Regiones\\BIOBIO.txt"); break; case 9: Cabecera->totalregiones[i]=crearArreglo("LA ARAUCANIA",Cabecera->totalregiones[i]>numero,"Regiones\\LA_ARAUCANIA.txt"); break; case 10: Cabecera->totalregiones[i]=crearArreglo("LOS RIOS",Cabecera->totalregiones[i]>numero,"Regiones\\LOS_RIOS.txt"); break; case 11: Cabecera->totalregiones[i]=crearArreglo("LOS LAGOS",Cabecera->totalregiones[i]>numero,"Regiones\\LOS_LAGOS.txt"); break; case 12:
56
Cabecera->totalregiones[i]=crearArreglo("AISEN DEL GRAL. CARLOS IBAEZ DEL CAMPO",Cabecera->totalregiones[i]->numero,"Regiones\\AISEN_DEL_GRAL._CARLOS _BAEZ_DEL_CAMPO.txt"); break; case 13: Cabecera->totalregiones[i]=crearArreglo("MAGALLANES Y DE LA ANTARTICA CHILENA",Cabecera->totalregiones[i]>numero,"Regiones\\MAGALLANES_Y_DE_LA_ANTARTICA_CHILENA.txt"); break; case 14: Cabecera->totalregiones[i]=crearArreglo("METROPOLITANA DE SANTIAGO",Cabecera>totalregiones[i]->numero,"Regiones\\METROPOLITANA_DE_SANTIAGO.txt"); break; } } for(i=0;i<15;i++) { if(Cabecera->totalregiones[i]->numero !=-1) AgregarClientes(Cabecera->totalregiones[i]->prov,&(*inicioCliente)); else Cabecera->totalregiones[i]->prov =NULL; } }
struct regiones * crearArreglo(char buffer[] ,int numregion, char ruta[]) { struct regiones *nodo=NULL;
57
if(VecIdent) { nodo = (struct regiones *)malloc(sizeof(struct regiones )); nodo->nombre = (char *)malloc(sizeof(char)*(strlen(buffer)+1)); strcpy(nodo->nombre,buffer); nodo->numero = numregion; nuevo=cargarProvi(ruta,VecIdent); nodo->prov =nuevo; return nodo; } else return NULL ;
struct provincia * cargarProvi(char ruta[],int *VecIdent) { FILE *Provi=NULL; struct provincia *nuevo=NULL, *nodo=NULL, *tmp=NULL; 58
while (fgets(linea,100,Provi)!=NULL) { if(!nuevo) { nuevo= (struct provincia *)malloc(sizeof(struct provincia)); nuevo->nombre=(char *)malloc(sizeof(char)*(strlen(linea)+1)); strcpy(nuevo->nombre,linea); nuevo->identificador=VecIdent[i]; i++ ; nuevo->sig=NULL; nuevo->opcion=cont; cont++; 59
rutacondo = ruta2(nuevo->identificador); Respuesta = ComprobarCondominios(nuevo->identificador,&NumCondominios,rutacondo); nuevo->condom= Respuesta; } else { tmp=nuevo; nodo =(struct provincia *)malloc(sizeof(struct provincia)); nodo->nombre=(char *)malloc(sizeof(char)*(strlen(linea)+1)); strcpy(nodo->nombre,linea); while(tmp->sig!=NULL) tmp=tmp->sig; nodo->identificador=VecIdent[i]; i++; rutacondo = ruta2(nodo->identificador); Respuesta = ComprobarCondominios(nodo->identificador,&NumCondominios,rutacondo); nodo->condom = Respuesta; nodo->sig=NULL; nodo->opcion=cont; cont++; tmp->sig=nodo; } }
} fclose(Provi); 60
return (nuevo); } int * VectorIdent(char *ident) { int cont = 0 , cantidadId, *VecIdent = NULL, i=0; FILE *ARCHIIDENT=NULL;
ARCHIIDENT = fopen(ident,"r");
if(!ARCHIIDENT) { printf("ERROR AL ABRIR EL ARCHIVO 2626"); exit(0) ; } else { while(!feof(ARCHIIDENT)) { if(cont==0) { fscanf(ARCHIIDENT,"%d\n",&cantidadId); if(cantidadId==0) return NULL; else { 61
fclose(ARCHIIDENT);
return VecIdent ; }
case 2: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\2.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\2.txt"); return rutad; break; case 3: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\3.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\3.txt"); return rutad; break; case 4: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\4.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\4.txt"); return rutad; break; case 5: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\5.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\5.txt"); return rutad; break; case 6: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\6.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\6.txt"); 63
return rutad; break; case 7: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\7.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\7.txt"); return rutad; break; case 8: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\8.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\8.txt"); return rutad; break; case 9: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\9.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\9.txt"); return rutad; break; case 10: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\10.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\10.txt"); return rutad; break; case 11: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\11.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\11.txt"); return rutad; 64
break; case 12: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\12.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\12.txt"); return rutad; break; case 13: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\13.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\13.txt"); return rutad; break; case 14: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\14.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\14.txt"); return rutad; break; case 15: rutad = (char *)malloc(sizeof(char)* (strlen("IDENTIFICADOR\\15.txt")+1)); strcpy(rutad,"IDENTIFICADOR\\15.txt"); return rutad; break; } }
{ FILE *Condo=NULL,*ID = NULL; int provin,condomin,i,esta=0, auxCondomin, e=0, cuenta_stock=0, *Vector, cont = 0; struct condominio *inicio=NULL, *nodo=NULL, *tmp=NULL; char *rutaId=NULL;
Condo=fopen("CONDOS.txt","r");
if(!Condo) { printf("ERROR ARCHIVO NO ENCONTRADO"); exit(0); } else { while(!feof(Condo)) { fscanf(Condo,"%d %d\n",&provin,&condomin); if(provin==identificador) { Vector = (int *)malloc(sizeof(int)*condomin); rutaId = RutaIdentCondo(provin) ; ID = fopen(rutaId,"r");
while(!feof(ID)) { 66
fscanf(ID,"%d",&Vector[e]); e++; } fclose(ID); esta=1; for(i=0;i<condomin;i++) { auxCondomin=condomin; if(i==0) cont = 3 ; agregarcondominioarbol(&inicio,Vector[i],rutacondo,i+1,&cont); cont = cont+3 ; } } } } fclose(Condo);
if(esta!=0) { tmp=inicio; RecorrerArbolParaDepa(tmp, &cuenta_stock) ; } return (inicio); } void RecorrerArbolParaDepa (struct condominio *raiz, int *cuenta_stock) 67
68
struct condominio* buscarCondoArbol(struct condominio *raiz, struct condominio **ant, int valor) { int enc; struct condominio *anterior; enc=0; anterior=NULL;
while( (raiz) && !enc) { if(raiz->id==valor) { enc=1; } else { anterior=raiz; if(valor<raiz->id) { raiz=raiz->izq; } else { raiz=raiz->der; } } } 69
void agregarcondominioarbol(struct condominio **raiz, int valor,char *rutaCondo, int Opcion, int *cont) { struct condominio *nuevo,*ant,*p;
p=buscarCondoArbol(*raiz, &ant, valor); if(!p) { nuevo = (struct condominio*)malloc(sizeof(struct condominio)); nuevo->id = valor; Copiardatos(nuevo,rutaCondo,Opcion,cont); nuevo->izq=nuevo->der=NULL;
else { ant->der=nuevo; } }
void Copiardatos(struct condominio *nuevo ,char *rutacondo, int Opcion, int *cont) { FILE *Caracteristicas=NULL; int contadorAux=1, NumeroEdificio=0,ContOpcion=1; char linea[150],*help, linea2[150], linea3[150]; struct condominio *tmp=nuevo;
else { while (contadorAux<= (*cont)) { // fgets(linea,100,Caracteristicas); fgets(linea2,100,Caracteristicas) ; fgets(linea3,100,Caracteristicas ) ; contadorAux= contadorAux + 3 ; } fclose(Caracteristicas);
for(i=0;i<numeroEdi;i++) { if(!nuevo) { nodo = (struct edificio *)malloc(sizeof(struct edificio)); nodo->sig=NULL; nodo->opcion= i+1; nuevo=nodo; } else { tmp=nuevo; while(tmp->sig!=NULL) tmp=tmp->sig; nodo = (struct edificio *)malloc(sizeof(struct edificio)); nodo->sig=NULL; nodo->opcion=i+1; tmp->sig=nodo; } } if(nuevo) CargarEdi(nuevo,NomCondominio,&(*stock)); 73
return nuevo; } char * CrearRuta (char *NomCondominio) { int num; char *cadena0 = "\\"; char *cadena1 = ".txt"; char cadena2[20]; char *cadena3 = "EDIFICIOS"; char cadena4[500]; char *ruta=NULL;
num=(strlen(NomCondominio))-1; strncpy(cadena2,NomCondominio,num); cadena2[num]= '\0'; strcpy(cadena4, cadena3); strcat(cadena4, cadena0); strcat(cadena4, cadena2); strcat(cadena4, cadena1); ruta = (char *)malloc(sizeof(char)*(strlen(cadena4)+1)); strcpy(ruta,cadena4);
return ruta; }
74
char * CrearRutaDepa (char *NomDepa) { int num; char *cadena0 = "\\"; char *cadena1 = ".txt"; char cadena2[20]; char *cadena3 = "DEPARTAMENTOS"; char cadena4[500]; char *ruta=NULL;
num=(strlen(NomDepa))-1; strncpy(cadena2,NomDepa,num); cadena2[num]= '\0'; strcpy(cadena4, cadena3); strcat(cadena4, cadena0); strcat(cadena4, cadena2); strcat(cadena4, cadena1); ruta = (char *)malloc(sizeof(char)*(strlen(cadena4)+1)); strcpy(ruta,cadena4);
return ruta; }
void CargarEdi(struct edificio *nuevo, char *NomCondominio, int *stock) { FILE *Edi=NULL; 75
struct edificio *tmp=nuevo, *tmp2=nuevo; int cont=1; char *cadena4=NULL, linea[500], *help=NULL;
Edi = fopen(cadena4,"r"); if(!Edi) { printf("ERROR AL ABRIR EL ARCHIVO 666"); exit(0); } else { while (fgets(linea,100,Edi)!=NULL) { switch (cont) { case 1: tmp->nombre_edificio = (char *)malloc(sizeof(char)*(strlen(linea)+1)); strcpy(tmp->nombre_edificio,linea); cont++; break; case 2: help = (char *)malloc(sizeof(char)*(strlen(linea)+1)); strcpy(help,linea); 76
} //arma los departamentos void ArmarDepartamentos (struct edificio *inicio, int *stock) { struct edificio *tmp=inicio; char *ruta=NULL; int x,y, i; FILE *DEPA=NULL; ruta = CrearRutaDepa(tmp->nombre_edificio); DEPA = fopen(ruta,"r"); 77
if(!DEPA) { printf("ERROR AL ABRIR EL ARCHIVO 1111"); exit(0); } else { if(tmp->tipo<1 || tmp->tipo>3) { printf("TIPO DE DEPARTAMENTOS INCOMPATIBLES"); exit (0); }
switch (tmp->tipo) // esto es solo para comproba que los departamentos del tipo que tienen que ser osea 1 2 3 si no es asi { // no se metera en el switch y no los crear case 1: tmp->tipos_departamentos = ConstruirDepa(tmp->tipo,DEPA,&(*stock)); // cambiar break; case 2: tmp->tipos_departamentos = ConstruirDepa(tmp->tipo,DEPA,&(*stock)); // cambiar break; case 3: tmp->tipos_departamentos = ConstruirDepa(tmp->tipo,DEPA,&(*stock)); // cambiar break; } } } 78
//copia los clientes en la matriz struct departamento *** ConstruirDepa (int tipo, FILE *DEPA, int *stock) { struct departamento ***edificio=NULL; struct cliente *clien=NULL; int i, j, num1=100,num2=102,num3=104,num4=106, auxStock=0, esta=0,fila,columna;
edificio = (struct departamento ***)malloc(sizeof(struct departamento **)*(fila)); for(i=0;i<fila;i++) { edificio[i] = (struct departamento **)malloc(sizeof(struct departamento *)*(columna)); } //CONSTRUIR DEPARTAMENTOS for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { edificio[i][j] = (struct departamento *)malloc(sizeof(struct departamento)); 79
} } // COPIAR EL ESTADO DEL DEPARTAMENTO for(i=0;i<fila;i++) { fscanf(DEPA,"%d %d %d %d\n",&edificio[i][0]->estado,&edificio[i][1]->estado,&edificio[i][2]>estado,&edificio[i][3]->estado); edificio[i][0]->numeroDepa = ((i+1) * num1)-(i*2) ; edificio[i][1]->numeroDepa = ((i+1) * num2)-(i*4) ; edificio[i][2]->numeroDepa = ((i+1) * num3)-(i*6) ; edificio[i][3]->numeroDepa = ((i+1) * num4)-(i*8) ;
} // AGREGAR LOS CLIENTES for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { if(edificio[i][j]->estado!=0) { clien = CopiarClientes (edificio[i][j]->estado); if(clien) { edificio[i][j]->clie= clien; auxStock = auxStock-1; } 80
else { printf("ERROR AL COPIAR LOS CLLIENTES 1313"); exit(0); } } else edificio[i][j]->clie=NULL; } } *stock= auxStock; return edificio; break;
case 2: fila = 10; columna = 3; auxStock = (fila*columna) + *stock; edificio = (struct departamento ***)malloc(sizeof(struct departamento **)*(fila));
for(i=0;i<fila;i++) { edificio[i] = (struct departamento **)malloc(sizeof(struct departamento *)*(columna)); } //CONSTRUIR DEPARTAMENTOS for(i=0;i<fila;i++) 81
} } // COPIAR EL ESTADO DEL DEPARTAMENTO for(i=0;i<fila;i++) { fscanf(DEPA,"%d %d %d\n",&edificio[i][0]->estado,&edificio[i][1]->estado,&edificio[i][2]>estado); edificio[i][0]->numeroDepa = ((i+1) * num1)-(i*2) ; edificio[i][1]->numeroDepa = ((i+1) * num2)-(i*2) ; edificio[i][2]->numeroDepa = ((i+1) * num3)-(i*2) ; } // AGREGAR LOS CLIENTES
{ edificio[i][j]->clie= clien; auxStock = auxStock-1; } else { printf("ERROR AL COPIAR LOS CLLIENTES 1313"); exit(0); } } else edificio[i][j]->clie=NULL; } } *stock= auxStock;
case 3:
fila = 12; columna = 3; auxStock = (fila*columna) + *stock; edificio = (struct departamento ***)malloc(sizeof(struct departamento **)*(fila));
83
for(i=0;i<fila;i++) { edificio[i] = (struct departamento **)malloc(sizeof(struct departamento *)*(columna)); } //CONSTRUIR DEPARTAMENTOS for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { edificio[i][j] = (struct departamento *)malloc(sizeof(struct departamento));
} } // COPIAR EL ESTADO DEL DEPARTAMENTO for(i=0;i<fila;i++) { fscanf(DEPA,"%d %d %d\n",&edificio[i][0]->estado,&edificio[i][1]->estado,&edificio[i][2]>estado); edificio[i][0]->numeroDepa = ((i+1) * num1)-(i*2) ; edificio[i][1]->numeroDepa = ((i+1) * num2)-(i*2) ; edificio[i][2]->numeroDepa = ((i+1) * num3)-(i*2) ; } // AGREGAR LOS CLIENTES
for(i=0;i<fila;i++) { 84
for(j=0;j<columna;j++) { if(edificio[i][j]->estado!=0) { clien = CopiarClientes (edificio[i][j]->estado); if(clien) { edificio[i][j]->clie= clien; auxStock = auxStock-1; } else { printf("ERROR AL COPIAR LOS CLLIENTES 1313"); exit(0); } } else edificio[i][j]->clie=NULL; } } *stock= auxStock; return edificio; break; } }
85
struct cliente * CopiarClientes (int id) { FILE *CLIENTE=NULL; char AuxNombre[50], AuxRut[15]; int AuxFono, AuxRegion, AuxProvincia, Auxid; struct cliente *clien=NULL;
CLIENTE =fopen("CLIENTES.txt","r");
if(!CLIENTE) { printf("ERROR AL ABRIR EL ARCHIVO 1313"); exit(0); } else { while(!feof(CLIENTE)) { fscanf(CLIENTE,"%d %d %d %s %s %d\n",&Auxid,&AuxRegion,&AuxProvincia,&AuxNombre,&AuxRut,&AuxFono); //printf("dsfdadssfadddadfsd %s\n",AuxRegion); if(Auxid==id) { clien = (struct cliente *)malloc(sizeof(struct cliente)); clien->id=Auxid; clien->region= AuxRegion; 86
clien->provincia = AuxProvincia; clien->nombre = (char *)malloc(sizeof(char)*(strlen(AuxNombre)+1)); strcpy(clien->nombre,AuxNombre); clien->rut = (char *)malloc(sizeof(char)*(strlen(AuxRut)+1)); strcpy(clien->rut,AuxRut); clien->fono=AuxFono;
} } fclose(CLIENTE); }
return clien; } void EncontrarClientes(struct edificio *edi, int tipo) { struct edificio *tmp=edi; int num,i=0,x,y,esta=0, fila ,columna, tip; struct cliente *nuevo=NULL;
while(tmp!=NULL) { tip = tmp->tipo; num = DepaporTipo(tip,&fila,&columna); tmp->clien = (struct cliente **)malloc(sizeof(struct cliente *)*(num));
87
} }
int num=0;
switch (tipo) { case 1: num=(10*4); *fila=10; *columna = 4; return num; break; case 2: num=(10*3); //cambiar *fila=10; *columna = 3; return num; break; case 3: num=(12*3); *fila=12; *columna = 3; return num; //cambiar break; } }
{ int i, NumCondominios; struct provincia *nuevo1=NULL; struct condominio *nuevo2=NULL; FILE *CONDO=NULL; CONDO = fopen("CONDOS.txt","w"); //limpiamos el txt CONDOS
else { CONDO = fopen("CONDOS.txt","a"); //anexamos al final if(!CONDO) { printf("ERROR AL ABRIR EL ARCHIVO 777"); exit(0); } else { NumCondominios = ContarCondominios (nuevo2); fprintf(CONDO,"%d %d\n",nuevo1->identificador,NumCondominios); fclose (CONDO); actualizarCondominios(nuevo2,nuevo1->identificador); actualizarDepa(nuevo2); nuevo1=nuevo1->sig; } } } }
} return 1; }
{ FILE *DEPA=NULL; char *rutaDepa=NULL; struct edificio *nuevo4=NULL; struct pila *cima = NULL ; push (&cima,NULL);
while (nuevo2!=NULL) { rutaDepa = CrearRuta(nuevo2->nombre_condominio); DEPA = fopen(rutaDepa,"w"); if(!DEPA) { printf("ERROR AL ABRIR EL ARCHIVO 1010"); exit(0); } else fclose(DEPA); nuevo4 = nuevo2->edi; DEPA = fopen(rutaDepa,"a"); while(nuevo4!=NULL) { fprintf(DEPA,"%s",nuevo4->nombre_edificio); fprintf(DEPA,"%d\n",nuevo4->tipo); nuevo4=nuevo4->sig; } 92
fclose(DEPA);
if(nuevo2->der) push(&cima,nuevo2->der); if(nuevo2->izq) nuevo2 = nuevo2->izq ; else nuevo2 = pop(&cima) ; } } void actualizarCondominios (struct condominio *nuevo2, int identificador) { FILE *CONDO=NULL, *ID =NULL; char *ruta=NULL ,copiado[500], *rutaId = NULL; int lineas; struct pila *cima = NULL ;
ID = fopen(rutaId,"w"); fclose(ID) ;
while(nuevo2!=NULL) { CONDO = fopen (ruta,"a"); lineas = (strlen(nuevo2->nombre_condominio)) - 1 ; strcpy(copiado,nuevo2->nombre_condominio); copiado[lineas] = '\0'; fprintf(CONDO,"%s\n",copiado);
} else { fprintf(ID,"%d\n",nuevo2->id); }
fclose(ID) ;
fclose (CONDO); }
int ContarCondominios (struct condominio *inicio) { struct condominio *tmp = inicio; int contador=0;
RecorridoContarCondo(tmp,&contador) ; 95
return contador ; }
void RecorridoContarCondo(struct condominio *arbol, int *contador) { if(arbol) { *contador = *contador + 1 ; RecorridoContarCondo(arbol->izq,contador); RecorridoContarCondo(arbol->der,contador);
} return ; }
char * ruta2(int identificador) { char *rutad=NULL; switch (identificador) { case 1: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\1.txt")+1)); strcpy(rutad,"CONDOMINIOS\\1.txt"); return rutad; break; 96
case 2: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\2.txt")+1)); strcpy(rutad,"CONDOMINIOS\\2.txt"); return rutad; break; case 3: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\3.txt")+1)); strcpy(rutad,"CONDOMINIOS\\3.txt"); return rutad; break; case 4: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\4.txt")+1)); strcpy(rutad,"CONDOMINIOS\\4.txt"); return rutad; break; case 5: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\5.txt")+1)); strcpy(rutad,"CONDOMINIOS\\5.txt"); return rutad; break; case 6: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\6.txt")+1)); strcpy(rutad,"CONDOMINIOS\\6.txt"); return rutad; break; 97
case 7: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\7.txt")+1)); strcpy(rutad,"CONDOMINIOS\\7.txt"); return rutad; break; case 8: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\8.txt")+1)); strcpy(rutad,"CONDOMINIOS\\8.txt"); return rutad; break; case 9: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\9.txt")+1)); strcpy(rutad,"CONDOMINIOS\\9.txt"); return rutad; break; case 10: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\10.txt")+1)); strcpy(rutad,"CONDOMINIOS\\10.txt"); return rutad; break; case 11: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\11.txt")+1)); strcpy(rutad,"CONDOMINIOS\\11.txt"); return rutad; break; case 12: 98
rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\12.txt")+1)); strcpy(rutad,"CONDOMINIOS\\12.txt"); return rutad; break; case 13: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\13.txt")+1)); strcpy(rutad,"CONDOMINIOS\\13.txt"); return rutad; break; case 14: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\14.txt")+1)); strcpy(rutad,"CONDOMINIOS\\14.txt"); return rutad; break; case 15: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\15.txt")+1)); strcpy(rutad,"CONDOMINIOS\\15.txt"); return rutad; break; case 16: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\16.txt")+1)); strcpy(rutad,"CONDOMINIOS\\16.txt"); return rutad; break; case 17: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\17.txt")+1)); 99
strcpy(rutad,"CONDOMINIOS\\17.txt"); return rutad; break; case 18: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\18.txt")+1)); strcpy(rutad,"CONDOMINIOS\\18.txt"); return rutad; break; case 19: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\19.txt")+1)); strcpy(rutad,"CONDOMINIOS\\19.txt"); return rutad; break; case 20: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\20.txt")+1)); strcpy(rutad,"CONDOMINIOS\\20.txt"); return rutad; break; case 21: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\21.txt")+1)); strcpy(rutad,"CONDOMINIOS\\21.txt"); return rutad; break; case 22: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\22.txt")+1)); strcpy(rutad,"CONDOMINIOS\\22.txt"); 100
return rutad; break; case 23: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\23.txt")+1)); strcpy(rutad,"CONDOMINIOS\\23.txt"); return rutad; break; case 24: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\24.txt")+1)); strcpy(rutad,"CONDOMINIOS\\24.txt"); return rutad; break; case 25: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\25.txt")+1)); strcpy(rutad,"CONDOMINIOS\\25.txt"); return rutad; break; case 26: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\26.txt")+1)); strcpy(rutad,"CONDOMINIOS\\26.txt"); return rutad; break; case 27: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\27.txt")+1)); strcpy(rutad,"CONDOMINIOS\\27.txt"); return rutad; 101
break; case 28: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\28.txt")+1)); strcpy(rutad,"CONDOMINIOS\\28.txt"); return rutad; break; case 29: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\29.txt")+1)); strcpy(rutad,"CONDOMINIOS\\29.txt"); return rutad; break; case 30: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\30.txt")+1)); strcpy(rutad,"CONDOMINIOS\\30.txt"); return rutad; break; case 31: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\31.txt")+1)); strcpy(rutad,"CONDOMINIOS\\31.txt"); return rutad; break; case 32: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\32.txt")+1)); strcpy(rutad,"CONDOMINIOS\\32.txt"); return rutad; break; 102
case 33: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\33.txt")+1)); strcpy(rutad,"CONDOMINIOS\\33.txt"); return rutad; break; case 34: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\34.txt")+1)); strcpy(rutad,"CONDOMINIOS\\34.txt"); return rutad; break; case 35: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\35.txt")+1)); strcpy(rutad,"CONDOMINIOS\\35.txt"); return rutad; break; case 36: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\36.txt")+1)); strcpy(rutad,"CONDOMINIOS\\36.txt"); return rutad; break; case 37: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\37.txt")+1)); strcpy(rutad,"CONDOMINIOS\\37.txt"); return rutad; break; case 38: 103
rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\38.txt")+1)); strcpy(rutad,"CONDOMINIOS\\38.txt"); return rutad; break; case 39: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\39.txt")+1)); strcpy(rutad,"CONDOMINIOS\\39.txt"); return rutad; break; case 40: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\40.txt")+1)); strcpy(rutad,"CONDOMINIOS\\40.txt"); return rutad; break; case 41: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\41.txt")+1)); strcpy(rutad,"CONDOMINIOS\\41.txt"); return rutad; break; case 42: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\42.txt")+1)); strcpy(rutad,"CONDOMINIOS\\42.txt"); return rutad; break; case 43: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\43.txt")+1)); 104
strcpy(rutad,"CONDOMINIOS\\43.txt"); return rutad; break; case 44: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\44.txt")+1)); strcpy(rutad,"CONDOMINIOS\\44.txt"); return rutad; break; case 45: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\45.txt")+1)); strcpy(rutad,"CONDOMINIOS\\45.txt"); return rutad; break; case 46: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\46.txt")+1)); strcpy(rutad,"CONDOMINIOS\\46.txt"); return rutad; break; case 47: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\47.txt")+1)); strcpy(rutad,"CONDOMINIOS\\47.txt"); return rutad; break; case 48: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\48.txt")+1)); strcpy(rutad,"CONDOMINIOS\\48.txt"); 105
return rutad; break; case 49: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\49.txt")+1)); strcpy(rutad,"CONDOMINIOS\\49.txt"); return rutad; break; case 50: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\50.txt")+1)); strcpy(rutad,"CONDOMINIOS\\50.txt"); return rutad; break; case 51: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\51.txt")+1)); strcpy(rutad,"CONDOMINIOS\\51.txt"); return rutad; break; case 52: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\52.txt")+1)); strcpy(rutad,"CONDOMINIOS\\52.txt"); return rutad; break; case 53: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\53.txt")+1)); strcpy(rutad,"CONDOMINIOS\\53.txt"); return rutad; 106
break; case 54: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\54.txt")+1)); strcpy(rutad,"CONDOMINIOS\\54.txt"); return rutad; break; case 55: rutad = (char *)malloc(sizeof(char)* (strlen("CONDOMINIOS\\55.txt")+1)); strcpy(rutad,"CONDOMINIOS\\55.txt"); return rutad; break; }
void AgregarClientes (struct provincia *prov,struct Encamp **inicioCliente) { struct provincia *tmp=prov;
} } void clienteDepa(struct condominio *inicio,struct Encamp **inicioCliente) { struct condominio *tmp=inicio; struct edificio *edi=NULL; int i; struct pila *cima = NULL ; push (&cima,NULL);
while(tmp) { //aca se hace la cuestion edi= tmp->edi; // me voy a los edificios while(edi!=NULL) // mientras sea distinto du NULL { for(i=0;i<edi->ultimo;i++) { if(edi->clien[i]) { crearEncap(&(*inicioCliente), edi->clien[i]); } } edi=edi->sig; }
108
} void crearEncap ( struct Encamp **inicioCliente, struct cliente *Copiar) { struct Encamp *tmp=NULL, *nodo=NULL;
if(!(*inicioCliente)) { nodo = (struct Encamp *)malloc(sizeof(struct Encamp)); nodo->sig=NULL; nodo->ant=NULL; nodo->EncapCliente=Copiar; *inicioCliente = nodo; } else { tmp= *inicioCliente; while(tmp->sig!=NULL) 109
tmp=tmp->sig; nodo = (struct Encamp *)malloc(sizeof(struct Encamp)); nodo->sig=NULL; nodo->ant=tmp; nodo->EncapCliente=Copiar; tmp->sig=nodo; } }
void menucompleto(struct Sistema *head) { int opadmono,claveadm, esta=0, actual; struct Sistema *tmp = head; while (esta==0) { printf("******************************\n"); printf("**********BIENVENIDO**********\n"); printf("******************************\n\n"); printf("\t***********Menu************"); printf("\n\t**ingrese tipo de usuario**\n \t**1) administrador \n "); printf("\t***************************\n"); printf("=> "); scanf("%i",&opadmono); **\n \t**2) vendedor **
system("cls");
switch (opadmono) { case 1: printf("ingrese clave de acceso al sistema de configuracion \n => "); scanf("%i",&claveadm); while(claveadm!=12345) { printf("clave erronea porfavor intente nuevamente\n => "); scanf("%i",&claveadm); } menuadmin(tmp); break;
case 2: menuvendedor(tmp); break; case 3: puts("GRACIAS POR UTILIZAR EL PROGRAMA"); return; 111
break; } system("cls"); actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n REALMENTE DESESAS SALIR 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta); if(esta!=0) esta=1; } } void menuvendedor(struct Sistema *head) { int OpcionCli, esta=0, respuesta, actual; struct cliente *nuevoCliente =NULL, *encontrado=NULL;
while (esta==0) { system("cls"); printf("*************Menu Vendedor*****************\n"); printf("** 1) Vender Departamento printf("** 2) Listar Clientes printf("** 3) Buscar Cliente printf("** 4) Buscar Estado Cliente printf("** 5) Salir **\n"); **\n"); **\n"); **\n"); **\n");
printf("*******************************************\n"); 112
scanf("%d",&OpcionCli);
while(OpcionCli>5&&OpcionCli<1) { printf("opcion no valida intente nuevamente"); scanf("%i",&OpcionCli); } switch(OpcionCli) { case 1: respuesta = VenderDepa(head->totalregiones,&nuevoCliente,head); if(respuesta==0) { puts("EL CLIENTE SE AGREGO SATISFACTORIAMENTE"); crearEncap(&head->EncapCliente,nuevoCliente); } else puts("ERROR AL VENDER EL DEPARTAMENTO"); break;
case 2: ListarClientes (head->EncapCliente); break; case 3: encontrado = BuscarCliente (head); if(!encontrado) 113
break; case 5: return; break; } actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta); if(esta!=0) esta=1; } } void MenuEdificio(struct Sistema *head) { int OpcionEdi, esta=0, agregarEdi,EliminarEdi, modificar, actual;
system("cls"); printf("*************Menu Administrador************\n"); printf("** 1) Agregar Edificio a un Condominio **\n"); printf("** 2) Eliminar Edificio a un Condominio **\n"); printf("** 3) Modificar Edificio a un Condominio **\n"); printf("** 4) Listar Edificio de un Condominio **\n"); printf("** 5) Salir **\n");
printf("*******************************************\n"); scanf("%d",&OpcionEdi);
while(OpcionEdi>5&&OpcionEdi<1) { printf("opcion no valida intente nuevamente"); scanf("%i",&OpcionEdi); } switch (OpcionEdi) { case 1: agregarEdi = AgregarEdificio(head); if(agregarEdi == 1) puts("EL EDIFICIO SE AGREGO CORRECTAMENTE"); else puts ("NO SE PUDO AGREGAR, INTENTELO NUEVAMENTE"); break;
case 2: 115
EliminarEdi = ElimiEdificio (head); if(EliminarEdi== 1) puts("EL EDIFICIO SE ELIMINO CORRECTAMENTE"); else puts("NO SE PUDO ELIMINAR, INTENTELO NUEVAMENTE"); break;
case 3: modificar=ModificarEdificio(head); if(modificar==1) puts("SE MODIFICO CORRECTAMENTE"); else printf("NO SE PUDO MODIFICAR"); break;
case 5: return; break; } actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); 116
} void MenuCondominio (struct Sistema *head) { int OpcionCondo, esta=0, agregar,Eliminar, modificar, actual;
while (esta==0) { system("cls"); printf("*************Menu Administrador************\n"); printf("** 1) Agregar Condominio printf("** 2) Eliminar Condominio printf("** 3) Modificar Condominio printf("** 4) Listar Condominio printf("** 5) Salir **\n"); **\n"); **\n"); **\n"); **\n");
printf("*******************************************\n"); scanf("%d",&OpcionCondo);
} switch (OpcionCondo) { case 1: agregar = AgregarCondominio(head); if(agregar==1) puts("Se Agrego Correctamente"); else puts("no se agrego nodo porfavor intente nuevamente"); break;
case 2: Eliminar = EliminarCondo(head); if(Eliminar == 0) puts("NO SE PUDO ELIMIAR"); else puts("SE ELIMINO EXITOSAMENTE"); break;
case 3: modificar=ModificarCondo(head); if(modificar==1) puts("SE MODIFICO CORRECTAMENTE"); else printf("NO SE PUDO MODIFICAR\n"); break; 118
case 5: return; break; } actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta); if(esta!=0) esta=1; }
} void MenuClientes(struct Sistema *head) { int OpcionCli, esta=0, respuesta, actual; struct cliente *nuevoCliente =NULL, *encontrado=NULL;
printf("*************Menu Administrador************\n"); printf("** 1) Vender Departamento printf("** 2) Eliminar Cliente printf("** 3) Buscar Cliente printf("** 4) Listar Clientes printf("** 5) Salir **\n"); **\n"); **\n"); **\n"); **\n");
printf("*******************************************\n"); scanf("%d",&OpcionCli);
case 1: respuesta = VenderDepa(head->totalregiones,&nuevoCliente,head); if(respuesta==0) { puts("EL CLIENTE SE AGREGO SATISFACTORIAMENTE"); crearEncap(&head->EncapCliente,nuevoCliente); } else puts("ERROR AL VENDER EL DEPARTAMENTO"); 120
break;
case 2: encontrado = EliminarCliente (head); if(encontrado) { respuesta = EliminarEncapCliente(&(head->EncapCliente), encontrado); if(respuesta==1) { puts("SE ELIMINO CORRECTAMENTE"); break; } else { puts("CLIENTE NO ELIMINADO CORRECTAMENTE"); break; } } else { puts("CLIENTE NO ENCONTRADO"); break; }
case 5: return; break; } actual = actualizar( head->totalregiones); actualizarCliente (head->EncapCliente); printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta); if(esta!=0) esta=1; } }
void menuadmin(struct Sistema *head) { int opcionadm,agregar,modificar,Region, Eliminar, agregarEdi,EliminarEdi, esta = 0, Opcion; struct condominio *condo;
122
while (esta==0) { printf("*************Menu Administrador***********\n"); printf("** 1) Condominio printf("** 2) Edificio printf("** 3) Cliente printf("** 4) Agregar una Region printf("** 5) Salir **\n"); **\n"); **\n"); **\n"); **\n");
printf("******************************************\n"); scanf("%d",&Opcion); while(Opcion>5&&Opcion<1) { printf("opcion no valida intente nuevamente"); scanf("%d",&Opcion); } switch (Opcion) { case 1: MenuCondominio(head); break;
case 3: 123
case 5 : return; }
system("cls"); puts("ESTA SALIENDO DEL MENU ADMINISTRIDOR"); printf("\n \n DESEA HACER OTRA OPERACION 0 = SI, CUALQUIER OTRA TECLA = NO \n => "); scanf("%d",&esta); if(esta!=0) esta=1; }
} void AgregarRegion(struct Sistema* Cabecera) { int RegionNueva, *VectorRegiones, max , aux,i,j, posicion; char *rutaRegion , *nombreRegion; FILE * REGIONES ;
while(RegionNueva<1 && RegionNueva>max) { printf("OPCION INCORRECTA, INGRESELA NUEVAMENTE \n => ") ; scanf("%d",&RegionNueva) ; }
posicion = 15 - max ;
switch (RegionNueva) { case 1: rutad = (char *)malloc(sizeof(char)* (strlen("ARICA Y PARINACOTA")+1)); strcpy(rutad,"ARICA Y PARINACOTA"); return rutad; break; 126
case 2: rutad = (char *)malloc(sizeof(char)* (strlen("TARAPACA")+1)); strcpy(rutad,"TARAPACA"); return rutad; break; case 3: rutad = (char *)malloc(sizeof(char)* (strlen("ANTOFAGASTA")+1)); strcpy(rutad,"ANTOFAGASTA"); return rutad; break; case 4: rutad = (char *)malloc(sizeof(char)* (strlen("ATACAMA")+1)); strcpy(rutad,"ATACAMA"); return rutad; break; case 5: rutad = (char *)malloc(sizeof(char)* (strlen("COQUIMBO")+1)); strcpy(rutad,"COQUIMBO"); return rutad; break; case 6: rutad = (char *)malloc(sizeof(char)* (strlen("VALPARAISO")+1)); strcpy(rutad,"VALPARAISO"); return rutad; break; 127
case 7: rutad = (char *)malloc(sizeof(char)* (strlen("LIBERTADOR GRAL. BERNARDO O'HIGGINS")+1)); strcpy(rutad,"LIBERTADOR GRAL. BERNARDO O'HIGGINS"); return rutad; break; case 8: rutad = (char *)malloc(sizeof(char)* (strlen("MAULE")+1)); strcpy(rutad,"MAULE"); return rutad; break; case 9: rutad = (char *)malloc(sizeof(char)* (strlen("BIOBIO")+1)); strcpy(rutad,"BIOBIO"); return rutad; break; case 10: rutad = (char *)malloc(sizeof(char)* (strlen("LA ARAUCANIA")+1)); strcpy(rutad,"LA ARAUCANIA"); return rutad; break; case 11: rutad = (char *)malloc(sizeof(char)* (strlen("LOS RIOS")+1)); strcpy(rutad,"LOS RIOS"); return rutad; break; case 12: 128
rutad = (char *)malloc(sizeof(char)* (strlen("LOS LAGOS")+1)); strcpy(rutad,"LOS LAGOS"); return rutad; break; case 13: rutad = (char *)malloc(sizeof(char)* (strlen("AISEN DEL GRAL. CARLOS BAEZ DEL CAMPO")+1)); strcpy(rutad,"AISEN DEL GRAL. CARLOS BAEZ DEL CAMPO"); return rutad; break; case 14: rutad = (char *)malloc(sizeof(char)* (strlen("MAGALLANES Y DE LA ANTARTICA CHILENA")+1)); strcpy(rutad,"MAGALLANES Y DE LA ANTARTICA CHILENA"); return rutad; break; case 15: rutad = (char *)malloc(sizeof(char)* (strlen("METROPOLITANA DE SANTIAGO")+1)); strcpy(rutad,"METROPOLITANA DE SANTIAGO"); return rutad; break; }
129
switch (RegionNueva) { case 1: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\ARICA_Y_PARINACOTA.txt")+1)); strcpy(rutad,"Regiones\\ARICA_Y_PARINACOTA.txt"); return rutad; break;
case 2: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\TARAPACA.txt")+1)); strcpy(rutad,"Regiones\\TARAPACA.txt"); return rutad; break; case 3: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\ANTOFAGASTA.txt")+1)); strcpy(rutad,"Regiones\\ANTOFAGASTA.txt"); return rutad; break; case 4: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\ATACAMA.txt")+1)); strcpy(rutad,"Regiones\\ATACAMA.txt"); return rutad; break; case 5: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\COQUIMBO.txt")+1)); strcpy(rutad,"Regiones\\COQUIMBO.txt"); 130
return rutad; break; case 6: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\VALPARAISO.txt")+1)); strcpy(rutad,"Regiones\\VALPARAISO.txt"); return rutad; break; case 7: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\LIBERTADOR_GRAL._BERNARDO_O'HIGGINS.txt")+1)); strcpy(rutad,"Regiones\\LIBERTADOR_GRAL._BERNARDO_O'HIGGINS.txt"); return rutad; break; case 8: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\MAULE.txt")+1)); strcpy(rutad,"Regiones\\MAULE.txt"); return rutad; break; case 9: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\BIOBIO.txt")+1)); strcpy(rutad,"Regiones\\BIOBIO.txt"); return rutad; break; case 10: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\LA_ARAUCANIA.txt")+1)); strcpy(rutad,"Regiones\\LA_ARAUCANIA.txt"); 131
return rutad; break; case 11: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\LOS_RIOS.txt")+1)); strcpy(rutad,"Regiones\\LOS_RIOS.txt"); return rutad; break; case 12: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\LOS_LAGOS.txt")+1)); strcpy(rutad,"Regiones\\LOS_LAGOS.txt"); return rutad; break; case 13: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\AISEN_DEL_GRAL._CARLOS _BAEZ_DEL_CAMPO.txt")+1)); strcpy(rutad,"Regiones\\AISEN_DEL_GRAL._CARLOS _BAEZ_DEL_CAMPO.txt"); return rutad; break; case 14: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\MAGALLANES_Y_DE_LA_ANTARTICA_CHILENA.txt")+1)); strcpy(rutad,"Regiones\\MAGALLANES_Y_DE_LA_ANTARTICA_CHILENA.txt"); return rutad; break; case 15: rutad = (char *)malloc(sizeof(char)* (strlen("Regiones\\METROPOLITANA_DE_SANTIAGO.txt")+1)); 132
case 1: printf("%d) ARICA Y PARINACOTA\n",num); break; case 2: printf("%d) TARAPACA\n",num); break; case 3: printf("%d) ANTOFAGASTA\n",num); break; case 4: printf("%d) ATACAMA\n",num); break; case 5: printf("%d) COQUIMBO\n",num); break; 133
case 6: printf("%d) VALPARAISO\n",num); break; case 7: printf("%d) LIBERTADOR GRAL. BERNARDO O'HIGGINS\n",num); break; case 8: printf("%d) MAULE\n",num); break; case 9: printf("%d) BIOBIO\n",num); break; case 10: printf("%d) LA ARAUCANIA\n",num); break; case 11: printf("%d) LOS RIOS\n",num); break; case 12: printf("%d) LOS LAGOS\n",num); break; case 13: printf("%d) AISEN DEL GRAL. CARLOS IBAEZ DEL CAMPO\n",num); break; case 14: printf("%d) MAGALLANES Y DE LA ANTARTICA CHILENA\n",num); 134
break; case 15: printf("%d) METROPOLITANA DE SANTIAGO\n",num); break ; } } int * GuardarVectorRegiones (struct regiones **totalesregiones, int *max) { int i , j, esta, pos, cont = 0, *Vector, x = 0;
} *max = cont ; return Vector ; } int ModificarEdificio(struct Sistema *head) { int Region, Eliminar, ident, ModificarEdi; struct provincia *provin =NULL; 136
if(CondoEscojido) { Edi = BuscarEdifi(CondoEscojido); if(Edi) { AuxEdi = BuscarEliminarEdi(Edi); ModificarEdi = ModificarEdifi(Edi,AuxEdi); return ModificarEdi; } return 0; } return 0; } int ModificarEdifi(struct edificio *inicio,struct edificio *Modificar) { struct edificio *tmp = inicio; int esta; char *nombreAntiguo;
137
while(tmp!=NULL) { if(tmp==Modificar) { nombreAntiguo =(char *)malloc(sizeof(char)*(strlen(tmp->nombre_edificio)+1)); strcpy(nombreAntiguo,tmp->nombre_edificio); esta = DatosModificarEdi(tmp); CargarClienteEdi(tmp,nombreAntiguo); return esta; } else tmp = tmp->sig; } return 0; } void CargarClienteEdi (struct edificio *nuevo, char *antiguo) { char *rutaNuevo, *rutaAntiguo; int num, fila, columna, i, j, estado; FILE *EDINUEVO, *EDIANTIGUO;
if(!EDINUEVO || !EDIANTIGUO) { puts("ERROR AL ABRIR EL ARCHIVO 2323"); exit(0); } else { num = DepaporTipo(nuevo->tipo,&fila,&columna);
for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { fscanf(EDIANTIGUO,"%d ",&estado); fprintf(EDINUEVO,"%d ",estado); } printf("\n"); fprintf(EDINUEVO,"\n"); } } fclose(EDIANTIGUO); fclose(EDINUEVO); EDIANTIGUO = fopen(rutaAntiguo,"w"); fclose(EDIANTIGUO); } 139
int DatosModificarEdi(struct edificio *tmp) { int Opcion, esta=0, num1; char Buffer[500], Buffer2[500];
if(Opcion<1 || Opcion>2) puts("OPCION INCORRECTA, INGRESELA NUEVAMENTE"); else esta=1; } switch (Opcion) {
case 1: fflush(stdin); printf("Ingrese el nuevo nombre \n => "); scanf("%[^\n]",Buffer); num1 = (strlen(Buffer)); tmp->nombre_edificio = (char *)malloc(sizeof(char)* (strlen(Buffer)+2)); 140
} int ModificarCondo(struct Sistema *head) { int Region, ident, Modificar; struct provincia *provin; struct condominio *CondoEscojido, *AuxCondo;
141
else return 0; } } int ModificarCondominio(struct condominio *inicio,struct condominio *Modificar) { struct condominio *tmp, *ant; int esta;
tmp = buscarCondoArbol(inicio,&ant,Modificar->id) ; if(tmp) { esta = DatosModificar(tmp); return esta; } else return 0; } int DatosModificar(struct condominio *tmp) { 142
int Opcion, esta=0, num1, num2; char Buffer[500], *aux, Buffer2[500], *aux2;
while(esta==0) { puts("QUE DESEA MODIFICAR"); puts("\t 1 = Nombre"); puts("\t 2 = Direccion"); puts("\t 3 = Ambas"); puts("\t 4 = Salir"); scanf("%d",&Opcion);
if(Opcion<1 || Opcion>4) puts("OPCION INCORRECTA, INGRESELA NUEVAMENTE"); else esta=1; } switch (Opcion) {
case 1: fflush(stdin); printf("Ingrese el nuevo nombre \n => "); scanf("%[^\n]",Buffer); num1 = (strlen(Buffer)); tmp->nombre_condominio = (char *)malloc(sizeof(char)* (strlen(Buffer)+2)); 143
case 2: fflush(stdin); printf("Ingrese las nuevas caracteristicas \n => "); scanf("%[^\n]",Buffer); num1 = (strlen(Buffer)); tmp->caracteristicas_condominio = (char *)malloc(sizeof(char)* (strlen(Buffer)+2)); Buffer[num1]= '\n'; Buffer[num1+1]= '\0'; strcpy(tmp->caracteristicas_condominio,Buffer); return 1; break;
case 3: fflush(stdin); printf("Ingrese el nuevo nombre \n => "); scanf("%[^\n]",Buffer); fflush(stdin); printf("Ingrese las nuevas caracteristicas \n => "); scanf("%[^\n]",Buffer2); num1 = (strlen(Buffer)); 144
num2 = (strlen(Buffer2)); tmp->nombre_condominio= (char *)malloc(sizeof(char)* (strlen(Buffer)+2)); tmp->caracteristicas_condominio = (char *)malloc(sizeof(char)* (strlen(Buffer2)+2)); Buffer[num1]= '\n'; Buffer[num1+1]= '\0'; Buffer2[num2]= '\n'; Buffer2[num2+1]= '\0'; strcpy(tmp->nombre_condominio,Buffer); strcpy(tmp->caracteristicas_condominio,Buffer2); return 1; break;
case 4: return 0; } }
struct condominio * BuscarCondoModificar(struct condominio *inicio) { struct condominio *auxCondo = NULL, *encontrado; int Opcion, esta=0;
puts("NOMBRE DE LOS CONDOMINIOS"); puts("ESCOJA EL CONDOMINIO EL CUAL SE MODIFICARA"); while (esta==0) { 145
encontrado = ComprobarOpcionCondo(auxCondo,Opcion) ; if(encontrado) return encontrado ; //////////// COMPROBAR ////////////// printf("OPCION INCORRECTA, INGRESELA NUEVAMENTE"); puts("DESEA SEGUIR BUSCANDO, 0= SI, CUALQUIER TECLA = NO"); scanf("%d",&esta);
if(esta!=0) return NULL; } } void ListarEdificio (struct Sistema *head) { int Region, Eliminar, ident; struct provincia *provin =NULL; struct condominio *CondoEscojido=NULL; struct edificio *Edi =NULL, *AuxEdi = NULL;
CondoEscojido = BuscarCondo(provin,&ident); if(CondoEscojido) { Edi = BuscarEdifi(CondoEscojido); if(Edi) MostarEdi(Edi); else puts("NO SE PUEDEN MOSTRAR LOS EDIFICIOS");
} else puts ("NO SE PUEDEN MOSTRAR LOS EDIFICIOS"); } void MostarEdi(struct edificio *Edi) { while (Edi!=NULL) { printf("%d ) %s",Edi->opcion,Edi->nombre_edificio); printf("\t tipo de Edificio %d \n",Edi->tipo); Edi=Edi->sig; }
} int ElimiEdificio (struct Sistema *head) { int Region, Eliminar, ident; 147
struct provincia *provin =NULL; struct condominio *CondoEscojido=NULL; struct edificio *Edi =NULL, *AuxEdi = NULL;
Region=buscar_prov(head); provin = head->totalregiones[Region]->prov; CondoEscojido = BuscarCondo(provin,&ident); if(CondoEscojido) { Edi = BuscarEdifi(CondoEscojido); if(Edi) { AuxEdi = BuscarEliminarEdi (Edi); Eliminar = EliminarEdificio(&Edi,AuxEdi,CondoEscojido); if(Eliminar== 1) return 1; else return 0; } else return 0; } else return 0; } int AgregarEdificio(struct Sistema *head) 148
{ int Region,agregar, ident; struct provincia *provin = NULL; struct condominio *CondoEscojido = NULL; struct edificio *Edi=NULL, *AuxEdi=NULL;
if(CondoEscojido) { Edi = BuscarEdifi(CondoEscojido); if(Edi) { //AuxEdi = BuscarEliminarEdi(Edi); agregar = AgregarEdificioNuevo(&(Edi), CondoEscojido); if(agregar == 1) return 1; else return 0; } else return 0; } else 149
return 0;
} void ListarCondominios (struct Sistema *head) { int i,j=1; struct provincia *inicio = NULL; struct condominio *iniciocondom= NULL;
for(i=0;i<15;i++) { if(head->totalregiones[i]->numero != -1) { inicio= head->totalregiones[i]->prov; while(inicio!=NULL) { iniciocondom=inicio->condom; Mostrarinorden(iniciocondom); inicio=inicio->sig; } } } } void Mostrarinorden (struct condominio *arbol) {
150
if(arbol) { printf(" NOMBRE CONDOMINIO %s ",arbol->nombre_condominio); printf("CARACTERISTICAS %s", arbol->caracteristicas_condominio); printf("NUMERO DE EDIFICIO %d \n",arbol->numero_edificios); Mostrarinorden(arbol->izq); Mostrarinorden(arbol->der);
} return ; } void mostrarCondoArbol(struct condominio *raiz) { if(raiz) { mostrarCondoArbol(raiz->izq); printf("%d )%s ",raiz->opcion,raiz->nombre_condominio); mostrarCondoArbol(raiz->der);
} return ; } int AgregarCondominio(struct Sistema *head) { int Region, ident, agregar, idCondominio, Opcion, esta = 0; struct provincia *provin; 151
puts("SOLAMENTE SE AGREGA UN CONDOMINIO EN UNA REGION YA EXISTENTE") ; puts("SI QUIERE CREAR UNA REGION DIRIJASE A CREAR REGION");
int AgregarNuevoarbol(struct condominio **raiz,struct condominio *nuevo, int valor) { struct condominio *ant,*p;
152
if(!ant){ *raiz=nuevo; return 1 ; } else { if(valor<ant->id) { ant->izq=nuevo; return 1 ; } else { ant->der=nuevo; return 1 ; } }
} else 153
{ return 0 ; } }
int EliminarEdificio(struct edificio **inicio, struct edificio *Eliminar, struct condominio *condo) { struct edificio *tmp =NULL, *tmp2=NULL; struct pila *cima = NULL ; push (&cima,NULL); int esta = 0;
while (condo->edi!=(*inicio)) { if(condo->der) push(&cima,condo->der); if(condo->izq) condo = condo->izq ; else condo = pop(&cima) ; }
154
if(tmp == Eliminar) { if(esta==0) { (*inicio)= tmp->sig; free (tmp); condo->edi = *inicio; condo->numero_edificios = (condo->numero_edificios) - 1; return 1 ; } else { if(tmp->sig) { tmp2->sig = tmp->sig; free (tmp); condo->numero_edificios = (condo->numero_edificios) - 1; return 1; } else { 155
return 0; } struct edificio * BuscarEliminarEdi(struct edificio *inicio) { struct edificio *tmp = NULL; int Opcion, esta=0, esta2=0, res;
156
while (tmp!=NULL) { printf("%d ) %s",tmp->opcion,tmp->nombre_edificio); tmp=tmp->sig; } scanf("%d",&Opcion); tmp = inicio; while (esta2==0) { while(tmp!=NULL) { if(tmp->opcion == Opcion) { esta2=1; esta = 1; return tmp; } else tmp=tmp->sig; } if(esta2==0) { puts("OPCION INCORRECTA\n INGRESELA NUEVAMENTE"); esta2=1; esta = 0; } 157
} esta2 = 0; } } int AgregarEdificioNuevo(struct edificio **inicio, struct condominio *condo) { struct edificio *tmp=NULL, *aux= *inicio,*nodo=(struct edificio *)malloc(sizeof(struct edificio)); int cont, stock=0; struct pila *cima = NULL ; push (&cima,NULL);
while (condo->edi!=(*inicio)) { if(condo->der) push(&cima,condo->der); if(condo->izq) condo = condo->izq ; else condo = pop(&cima) ; }
if(!(*inicio)) 158
{ (*inicio) = nodo; condo->numero_edificios = (condo->numero_edificios) + 1; return 1; } else { tmp=*inicio; while(tmp->sig!=NULL) tmp=tmp->sig; nodo->sig =NULL; tmp->sig = nodo; condo->numero_edificios = (condo->numero_edificios) + 1; return 1; } return 0; } int contarEdificio(struct edificio *inicio) { int cont =0;
return cont; } int EliminarCondo(struct Sistema *head) { int Region, ident, Opcion,Eliminar; struct provincia *provin=NULL; struct condominio *CondoEscojido=NULL, *auxCondo =NULL, *encontrado=NULL; char NombreCondo[100];
} int elimCondo ( struct provincia *inicio) { struct provincia *tmp=NULL, *aux=NULL; int Opcion, esta2=0, res, esta=0, eliminado= 0;
tmp=tmp->sig; }
scanf("%d",&Opcion); aux=inicio; while(aux!=NULL) { if(aux->opcion==Opcion) { esta=1; if(aux->condom) eliminado = EliminadoCondominio(aux->condom,aux); else printf("NO SE ENCUENTRAN CONDOMINIO ASOCIADOS") ;
} if(esta==0) { tmp=inicio; printf("*****OPCION INCORRECTA, INGRESE NUEVAMENTE\n ***** DESEA SEGUIR BUSCANDO ***** \n 1=SI 2=NO"); 161
while(esta2==0) { scanf("%d",&res); if(res>2 || res<1) printf("OPCION INCORRECTA 1=SI 2=NO\n INGRESE NUEVAMENTE \n => "); else esta2=1; } if(res==1) { esta=0; esta2=0; } else { return 0; esta=1; } } } } struct condominio * ComprobarOpcionCondo (struct condominio *raiz, int Opcion) { struct pila *cima = NULL ; struct condominio *encontrado = NULL ; 162
push (&cima,NULL); while(raiz) { if(raiz->opcion == Opcion) { encontrado = raiz ; return encontrado ; } else { if(raiz->der) push(&cima,raiz->der); if(raiz->izq) raiz = raiz->izq ; else raiz = pop(&cima) ;
} return encontrado ; }
int EliminadoCondominio(struct condominio *inicio, struct provincia *provin) { struct condominio *auxCondo =inicio, *CondoEscojido=NULL, *encontrado=NULL, *tmp; 163
if(encontrado) { Eliminar = EliminarCondoArbol(&(inicio) ,encontrado->id); //provin->condom = inicio; SacarFicherCondo(provin->identificador); return Eliminar; } else return 1; }
return 1 ; return 0 ; }
int EliminarCondoArbol(struct condominio **raiz, int valor) { struct condominio *a1,*ab,*padre,*actual,*nodo; int aux;
} free(actual); actual=NULL; return 1; } else { padre = actual; if(actual->der) { nodo = actual->der; while(nodo->izq) { padre = nodo; nodo = nodo->izq; } } else { nodo = actual->izq; while(nodo->der) { padre = nodo; nodo = nodo->der; } } 166
if(!CONDO) { printf("ERROR AL ABRIR EL ARCHIVO 2121"); exit(0); } else fclose (CONDO); } int buscar_prov(struct Sistema *head)//busca la provincia donde se encuentra el condominio 167
{ int i,numeroregion,numeroprovincia,numerofinalprovincia, cont=0; struct condominio *auxiliarcon=NULL;//puntero qeu retornare despues struct provincia *auxiliarprov=NULL;
while(numeroregion>cont || numeroregion<1 ) { printf("opcion no valida intente nuevamente \n => "); scanf("%i",&numeroregion); } return numeroregion-1;
168
fflush(stdin); printf("Ingrese nuevo nombre del condominio"); scanf("%[^\n]",bufer_nombre); nuevo->nombre_condominio = (char *)malloc(sizeof(char)*(strlen(bufer_nombre)+1)); strcpy(nuevo->nombre_condominio,bufer_nombre);
fflush(stdin); printf("ingrese pequea nueva descripcion del condominio"); scanf("%[^\n]",bufer_descripcion); nuevo->caracteristicas_condominio = (char *)malloc(sizeof(char)*(strlen(bufer_descripcion)+1)); strcpy(nuevo->caracteristicas_condominio,bufer_descripcion);
return 0;
char bufer_nombre[50],bufer_descripcion[5000],bufer_nedificio[10],bufer_numeroedif; struct condominio *nuevo=(struct condominio *)malloc(sizeof(struct condominio)); int cuentaStock = 0, num1, num2;
fflush(stdin); printf("\ningrese nombre del condominio\n"); scanf("%[^\n]",bufer_nombre); num1 = (strlen(bufer_nombre)); nuevo->nombre_condominio = (char *)malloc(sizeof(char)*(strlen(bufer_nombre)+2)); bufer_nombre[num1]= '\n'; bufer_nombre[num1+1]= '\0'; strcpy(nuevo->nombre_condominio,bufer_nombre);
fflush(stdin); printf(" ingrese pequea descripcion del condominio\n"); scanf("%[^\n]",bufer_descripcion); num1 = (strlen(bufer_descripcion)); nuevo->caracteristicas_condominio = (char *)malloc(sizeof(char)*(strlen(bufer_descripcion)+2)); bufer_descripcion[num1]= '\n'; 170
fflush(stdin); // crear solamente los departametos, ya que la otra funcion carga los datos if(nuevo->numero_edificios!=0) nuevo->edi = CrearDepaSolos(nuevo->numero_edificios,&cuentaStock); else nuevo->edi = NULL;
nuevo->stock = cuentaStock; nuevo->izq=nuevo->der=NULL; } //****CREA LOS EDIFICIOS PREGUNTANDO LOS NOMBRES Y LOS DATOS **/////// struct edificio * CrearDepaSolos(int numeroEdi,int *cuentaStock) { int i; struct edificio *nuevo=NULL, *nodo=NULL, *tmp=NULL;
{ nodo = (struct edificio *)malloc(sizeof(struct edificio)); nodo->sig=NULL; nodo->opcion= i+1; llenarDatosEdi(nodo,&(*cuentaStock)); // llena los datos de los departamentos uno a uno nuevo=nodo; } else { tmp=nuevo; while(tmp->sig!=NULL) tmp=tmp->sig; nodo = (struct edificio *)malloc(sizeof(struct edificio)); nodo->sig=NULL; nodo->opcion=i+1; llenarDatosEdi(nodo,&(*cuentaStock)); // llena los datos de los departamentos uno a uno tmp->sig=nodo; } } return nuevo; } void llenarDatosEdi(struct edificio *nodoLlenar, int *cuentaStock) { char Buffer[500], *rutaEdificio; int esta=0, stock = 0, num1; FILE *DEPARTA =NULL; 172
fflush(stdin); printf("Ingrese el nombre de %d Edificio",nodoLlenar->opcion); scanf("%[^\n]",Buffer); num1 = (strlen(Buffer)); nodoLlenar->nombre_edificio = (char * )malloc(sizeof(char)* (strlen(Buffer)+2)); Buffer[num1]= '\n'; Buffer[num1+1]= '\0'; strcpy(nodoLlenar->nombre_edificio,Buffer); fflush(stdin); while(esta==0) { printf("Ingrese el tipo del %d Edificio (Recuerde que son 3 tipos solamente)",nodoLlenar>opcion); scanf("%d",&nodoLlenar->tipo); if(nodoLlenar->tipo<1 || nodoLlenar->tipo>3) puts("TIPO INCORRECTO INGRESE NUEVAMENTE"); else esta=1; } esta=0;
fflush(stdin); rutaEdificio = CrearRutaDepa(nodoLlenar->nombre_edificio); DEPARTA = fopen(rutaEdificio,"w"); //crea el archivo PonerEstadoDepa(DEPARTA, nodoLlenar); 173
fclose(DEPARTA); ArmarDepartamentos(nodoLlenar,&stock); *cuentaStock = *cuentaStock + stock; } void PonerEstadoDepa (FILE *DEPARTA, struct edificio *tmp) { int num, fila, columna, i, j;
num = DepaporTipo(tmp->tipo,&fila,&columna);
} struct provincia * busqueda_ubicacioncondo_aeliminar(struct regiones **totalregiones,int numeroregion,char *nombre_provincia) //buscar en que region y provincia eliminar o agregar un condominio { struct provincia *aux=totalregiones[numeroregion]->prov;
174
void SacarCondoFichero (struct condominio *Condo) { FILE *CONDO = NULL; char *ruta;
ruta = CrearRuta(Condo->nombre_condominio); CONDO = fopen(ruta,"w"); if(!CONDO) { printf("ERROR AL ABRIR EL ARCHIVO 2020"); exit(0); } else fclose (CONDO);
175
void actualizarCliente (struct Encamp *inicio) { struct Encamp *tmp = inicio; FILE *CLIENTE = NULL;
CLIENTE = fopen("CLIENTES.txt","w"); if(!CLIENTE) { printf("ERROR AL ABRIR EL ARCHIVO 1414"); exit(0); } else fclose(CLIENTE);
CLIENTE = fopen("CLIENTES.txt","a");
if(!CLIENTE) { printf("ERROR AL ABRIR EL ARCHIVO 1414"); exit(0); } else { while(tmp!=NULL) { printf("%s\n",tmp->EncapCliente->nombre) ; 176
int EliminarEncapCliente(struct Encamp **inicio, struct cliente *encontrado) { struct Encamp *tmp=NULL, *aux=NULL, *aux2=NULL;
return 1;
177
} tmp=*inicio; while(tmp!=NULL) { if(tmp->EncapCliente==encontrado) { aux=tmp; if(tmp->sig) { aux2=tmp->ant; aux2->sig=tmp->sig; free(aux); return 1; } else { aux2=tmp->ant; aux2->sig=NULL; free(aux); return 1; }
return 0; }
struct cliente * EliminarCliente (struct Sistema *Cabecera) { struct cliente *Encontrado=NULL; struct Encamp *Buscar = Cabecera->EncapCliente; int esta=0, Opcion, estado;
while(esta==0) { puts("BUSQUEDA DE CLLIENTES MEDIANTE POR : "); puts("1 = NOMBRE (SEPARAR APELLIDO CON UN GUIN BAJO _ )"); puts("2 = ID "); puts("3 = RUT"); puts("4 = SALIR"); scanf("%d",&Opcion); if(Opcion==1 || Opcion==2 || Opcion==3 || Opcion==4) esta=1; else puts("OPCION INCORRECTA.. INGRESELA NUEVAMENTE\n"); } switch (Opcion) { case 1: Encontrado = BusquedaClienteNom(Buscar); 179
break;
int ElimiClienteEncontrado (struct Sistema *Cabecera,struct cliente *Encontrado) { struct condominio *condo=NULL; struct provincia *Auxprovin =NULL, *provin=NULL; 180
struct edificio *edi; struct departamento *DepaCliente=NULL; int Region, esta=0, num , fila, columna; struct pila *cima = NULL ;
Region= (Encontrado->region)-1; Auxprovin = Cabecera->totalregiones[Region]->prov; provin = BuscarProvin(Auxprovin,Encontrado->provincia); condo= provin->condom; push (&cima,NULL);
while (condo!=NULL && esta==0) { edi = RecorridoEdi(condo,Encontrado); if(edi) esta=1; else { if(condo->der) push(&cima,condo->der); if(condo->izq) condo = condo->izq ; else condo = pop(&cima) ;
} 181
if(num==1) QuitarenLista(edi,Encontrado);
} void QuitarenLista(struct edificio *edi,struct cliente *Encontrado) { int i; struct cliente *Aux=NULL;
for(i=0;i<edi->ultimo;i++) { if(edi->clien[i]==Encontrado) { edi->clien[i]=NULL; } } Compactar(edi); } void Compactar(struct edificio *edi) { int i; 182
for(i=0;i<edi->ultimo;i++) { if(edi->clien[i]==NULL) { Aux = edi->clien[i]; edi->clien[i] = edi->clien[i+1]; edi->clien[i+1] = Aux; } } } int borraCliente(struct edificio *edi,int fila, int columna, struct cliente *Encontrado) { int i, j , hecho=0; struct departamento *DepaEncuen =NULL;
} } } SacarClienteFichero (edi,fila,columna); return hecho; } void SacarClienteFichero (struct edificio *edi,int fila,int columna) { FILE *ELCLIENTE =NULL; char *ruta ; int i, j;
ELCLIENTE = fopen (ruta,"w"); if(!ELCLIENTE) { printf("ERROR AL ABRIR EL ARCHIVO 1717"); exit(0); } else { for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { 184
fprintf(ELCLIENTE,"%d ",edi->tipos_departamentos[i][j]->estado); } fprintf(ELCLIENTE,"\n"); } } fclose(ELCLIENTE); } struct provincia * BuscarProvin(struct provincia *Auxprovin, int identi) {
struct cliente * BuscarCliente (struct Sistema *Cabecera) { int Opcion, esta=0; struct cliente *Encontrado=NULL; struct Encamp *Buscar = Cabecera->EncapCliente;
while(esta==0) 185
{ puts("BUSQUEDA DE CLLIENTES MEDIANTE POR : "); puts("1 = NOMBRE (SEPARAR APELLIDO CON UN GUIN BAJO _ )"); puts("2 = ID "); puts("3 = RUT"); puts("4 = SALIR"); scanf("%d",&Opcion); if(Opcion==1 || Opcion==2 || Opcion==3 || Opcion==4) esta=1; else puts("OPCION INCORRECTA.. INGRESELA NUEVAMENTE\n");
} switch (Opcion) { case 1: Encontrado = BusquedaClienteNom(Buscar); if(Encontrado) { Opciones(Encontrado,Cabecera); return Encontrado; } else return Encontrado; break;
186
case 2: Encontrado = BusquedaClienteId(Buscar); if(Encontrado) { Opciones(Encontrado,Cabecera); return Encontrado; } else return Encontrado; break;
case 3: Encontrado = BusquedaClienteRut(Buscar); if(Encontrado) { Opciones(Encontrado,Cabecera); return Encontrado; } else return Encontrado; break; } } struct cliente * BusquedaClienteRut(struct Encamp *Buscar) { char Buffer[15]; 187
puts ("BUSQUEDA HECHA MEDIANTE EL RUT DEL CLIENTE"); printf("\n Inngrese el rut del cleinte"); scanf("%s",&Buffer); while (Buscar!=NULL) { if(strcmp(Buscar->EncapCliente->rut,Buffer)==0) { Encontrado = Buscar->EncapCliente; Buscar=NULL; } else Buscar=Buscar->sig; }
return Encontrado; } struct cliente * BusquedaClienteId(struct Encamp *Buscar) { int id; struct cliente *Encontrado=NULL; system("cls");
printf("\n Inngrese la Id del cleinte"); scanf("%d",&id); while (Buscar!=NULL) { if(Buscar->EncapCliente->id==id) { Encontrado = Buscar->EncapCliente; Buscar=NULL; } else Buscar=Buscar->sig; }
return Encontrado; } void Opciones (struct cliente *Encontrado, struct Sistema *Cabecera) { int Opcion,esta=0;
while(esta==0) { printf("CLIENTE %s ",Encontrado->nombre); puts("QUE DESEA BUSCAR?"); puts("1 = La Region del Cliente"); puts("2 = La provincia"); puts("3 = El Condominio"); 189
puts("4 = El Departamento"); puts("5 = Toda la informacion asociada al Cliente"); scanf("%d",&Opcion); if((Opcion==1) || (Opcion==2) || (Opcion==3) || (Opcion==4) || (Opcion==5)) esta=1; else puts("OPCION INCORRECTA.. INGRESELA NUEVAMENTE\n"); } switch (Opcion) { case 1 : printf("CLIENTE %s :\n\n",Encontrado->nombre); printf("La Region %s \n",Cabecera->totalregiones[Encontrado->region-1]->nombre); break;
case 4: 190
case 5: printf("CLIENTE %s :\n\n",Encontrado->nombre); printf("La Region %s \n",Cabecera->totalregiones[Encontrado->region-1]->nombre); mostrarProvincia(Encontrado,Cabecera->totalregiones); mostrarCondominio(Encontrado,Cabecera->totalregiones); mostarDepa(Encontrado,Cabecera->totalregiones); } } void mostarDepa(struct cliente *Encontrado,struct regiones **totalregiones) { struct provincia *provi = totalregiones[Encontrado->region-1]->prov; struct condominio *condo=NULL; struct edificio *edi=NULL, *edificioEncotrado=NULL; struct departamento *DepaEncotrado=NULL; int esta=0, esta2=0, i,j, fila, columna, num; struct pila *cima = NULL ; push (&cima,NULL);
192
DepaEncotrado = RecorridoDepa(edificioEncotrado,fila,columna,Encontrado); printf("El departamento del cliente es : \n"); printf("Edificio %s Numero %d \n",edificioEncotrado->nombre_edificio,DepaEncotrado>numeroDepa);
} struct departamento * RecorridoDepa(struct edificio *edificioEncontrado,int fila,int columna,struct cliente *Encontrado) { int i, j ; struct departamento *DepaEncuen =NULL;
for(i=0;i<fila;i++) { for(j=0;j<columna;j++) { if(edificioEncontrado->tipos_departamentos[i][j]->clie == Encontrado) DepaEncuen = edificioEncontrado->tipos_departamentos[i][j]; } } return DepaEncuen; } struct edificio * RecorridoEdi(struct condominio *condo, struct cliente *Encontrado) { struct edificio *edi=condo->edi;
193
void mostrarCondominio(struct cliente *Encontrado,struct regiones **totalregiones) { struct provincia *provi = totalregiones[Encontrado->region-1]->prov; struct condominio *condo=NULL, *AuxCondo=NULL; struct edificio *edi=NULL; int esta=0, esta2=0, i;
if(!AuxCondo) { puts("NO SE ENCONTRO EL CLIENTE ") ; return ; } else esta2=1; } if(esta2==1) esta=1; } else provi=provi->sig; } printf("El cliente se encuentra en el condominio %s ",AuxCondo->nombre_condominio); printf("Ubicado en %s \n", AuxCondo->caracteristicas_condominio); } struct condominio * RecorridoCondo(struct edificio *edi, struct cliente *Encontrado, struct condominio *condo) 195
} edi=edi->sig;
} return Encontrado2; } void mostrarProvincia (struct cliente *Encontrado, struct regiones **totalregiones) { struct provincia *provi = totalregiones[Encontrado->region-1]->prov; int esta=0; while (provi!=NULL && esta==0) { 196
if(provi->identificador==Encontrado->provincia) { printf("La provincia del cliente es %s\n ",provi->nombre); esta=1; } else provi=provi->sig; } }
struct cliente * BusquedaClienteNom(struct Encamp *Buscar) { char Buffer[50]; struct cliente *Encontrado=NULL; system("cls");
puts ("BUSQUEDA HECHA MEDIANTE EL NOMBRE"); printf("\n Inngrese el Nombre del cliente (SEPARAR APELLIDO CON UN GUIN BAJO _ \n => "); scanf("%s",&Buffer); while (Buscar!=NULL) { if(strcmp(Buscar->EncapCliente->nombre,Buffer)==0) { Encontrado = Buscar->EncapCliente; Buscar=NULL; } 197
else Buscar=Buscar->sig; }
return Encontrado; } void ListarClientes (struct Encamp *tmp) { while(tmp!=NULL) { printf("Nombre %s \n",tmp->EncapCliente->nombre); printf("id %d \n",tmp->EncapCliente->id); printf("rut %s \n",tmp->EncapCliente->rut); tmp=tmp->sig; } } int VenderDepa(struct regiones **totalregiones, struct cliente **nuevoCliente2,struct Sistema *head) { int i,Region, respuesta=0, cont, ElegiPro,esta=0, esta2=0, ident, esta3 =0, Verificador; struct provincia *provin=NULL; struct condominio *CondoEscojido=NULL; struct edificio *DepaEscojido=NULL; struct cliente *nuevoCliente=NULL;
while(respuesta==0) { 198
while (esta3==0) { puts("ESCOJA UNA REGION\n"); for(i=0;i<15;i++) { if(totalregiones[i]->numero != -1) { printf(" %d ) = %s \n",i+1,totalregiones[i]->nombre); Verificador = i+1 ; }
printf("\n\n => "); scanf("%d",&Region); if(Region>Verificador || Region<1) puts("NUMERO INCORRECTO, INGRESELO NUEVAMENTE"); else esta3=1; } system("cls"); provin = totalregiones[Region-1]->prov; puts("ESCOJA UNA PROVINCIA"); printf("=> "); CondoEscojido = BuscarCondo(provin,&ident);
199
if(CondoEscojido) { printf("ESCOJA UN CONDOMINIO \n => "); DepaEscojido = BuscarEdifi(CondoEscojido); if(DepaEscojido && CondoEscojido->stock>0) { nuevoCliente = BuscarDepa(DepaEscojido,Region,ident,head); if(nuevoCliente) { *nuevoCliente2 = nuevoCliente; return 0; }
else return 1; } else { puts("LOS SENTIMOS, EL CONDOMINIO NO POSEE CONDOMINIOS MAS DEPARTAMENTOS"); puts("O NO HAY CONDOMINIOS"); puts("0= BUSCAR NUEVAMENTE, 1= SALIR"); while (esta2==0) { scanf("%d",&esta2);
} else { puts("OPCION INCORRECTA... INGRESE NUEVAMENTE "); puts("0= BUSCAR NUEVAMENTE, 1= SALIR"); esta2=0; } } respuesta=0; } } else { puts("LOS SENTIMOS, EL CONDOMINIO NO POSEE MAS DEPARTAMENTOS"); puts("O NO HAY CONDOMINIOS"); puts("0= BUSCAR NUEVAMENTE, 1= SALIR"); while (esta2==0) { scanf("%d",&esta2);
201
} else { puts("OPCION INCORRECTA... INGRESE NUEVAMENTE "); puts("0= BUSCAR NUEVAMENTE, 1= SALIR"); esta2=0; } } respuesta=0;
} esta2=0;
} } struct cliente * BuscarDepa(struct edificio *inicioEdi, int Region, int Provin,struct Sistema *head) { 202
struct edificio *tmp=NULL, *aux=NULL; struct cliente *nulo=NULL, *nuevo=NULL; int esta=0, esta2=0, Opcion;
scanf("%d",&Opcion); aux=inicioEdi; while(aux!=NULL) { if(aux->opcion==Opcion) { esta=1; tmp = aux; aux=NULL; } else { aux=aux->sig; 203
} if(esta==0) { tmp=inicioEdi; printf("*****OPCION INCORRECTA, INGRESE NUEVAMENTE\n ***** DESEA SEGUIR BUSCANDO ***** \n 1=SI 2=NO"); while(esta2==0) { scanf("%d",&esta); if(esta>2 || esta<1) printf("OPCION INCORRECTA 1=SI 2=NO\n INGRESE NUEVAMENTE \n => "); else esta2=1; } if(esta=1) esta=0; else return (nulo); } else {
} return nuevo;
struct cliente * MostrarDisponibles (struct edificio *edi, int Region, int Provin,struct Sistema *head) { struct edificio *tmp=edi; struct cliente *nuevoCliente=NULL; int i, j,fila,columna, num,NumDepa,comprobar, esta=0,filaOcupada,columnaOcupada;
printf("\n"); } puts("INGRESE EL NUMERO DE DEPARTAMENTO QUE QUIERE COMPRAR"); scanf("%d",&NumDepa); comprobar = coprobarDepa(tmp,fila,columna,NumDepa,&filaOcupada,&columnaOcupada); if(comprobar==1) { nuevoCliente = CrearNuevoCliente (NumDepa,Region,Provin,tmp->tipo,&head); tmp->tipos_departamentos[filaOcupada][columnaOcupada]->numeroDepa=NumDepa; tmp->tipos_departamentos[filaOcupada][columnaOcupada]->estado=nuevoCliente->id; tmp->tipos_departamentos[filaOcupada][columnaOcupada]->clie=nuevoCliente; tmp->clien[tmp->ultimo]=nuevoCliente; tmp->ultimo++; copiarIdFichero (nuevoCliente->id,tmp,fila,columna); return nuevoCliente; esta=1; } else { printf("INGRESO UN NUMERO INCORRECTO, INGRESE NUEVAMENTE\n"); } } return nuevoCliente; }
void copiarIdFichero (int id, struct edificio *Edi, int fila, int columna) 206
ruta = CrearRutaDepa(Edi->nombre_edificio);
NUEVOCLIENTE = fopen(ruta,"w"); if(!NUEVOCLIENTE) { printf("ERROR EN EL ARCHIVO 1616"); exit(0); } else { for (i=0;i<fila;i++) { for(j=0;j<columna;j++) { fprintf (NUEVOCLIENTE,"%d ",Edi->tipos_departamentos[i][j]->estado); } fprintf(NUEVOCLIENTE,"\n"); } } fclose(NUEVOCLIENTE);
207
struct cliente * CrearNuevoCliente (int NumDepa, int Region, int Provin,int tipodepa,struct Sistema **head) { int formadepago; struct ventas *headventas=(*head)->caeza; struct ventas *nuevaventa=(struct ventas *)malloc(sizeof(struct ventas)); struct cliente *nuevo=(struct cliente *)malloc(sizeof(struct cliente)); char Buffer[100];
fflush(stdin); puts("Ingrese el nombre del cliente : "); scanf("%s",&Buffer); nuevo->nombre = (char *)malloc(sizeof(char)*(strlen(Buffer)+1)); strcpy(nuevo->nombre,Buffer); fflush(stdin); puts("Ingrese su rut : "); scanf("%[^\n]",Buffer); nuevo->rut = (char *)malloc(sizeof(char)*(strlen(Buffer)+1)); strcpy(nuevo->rut,Buffer); nuevo->region = Region; nuevo->provincia = Provin; puts("Ingrese el fono del cliente, (en caso de no tener ponga un 0)"); scanf("%d",&nuevo->fono); //desde aqui lo nuevo en la funcion extra 208
puts("ingrese medio de pago \n1)efectivo\n2)cuotas(10)"); scanf("%d",&formadepago); if(formadepago==2) { puts("ingrese numero de cuotas a pagar al momento de la compra(si no pagara ahora poner 0)"); do { scanf("%d",nuevaventa->cuotaspagadas); }while(nuevaventa->cuotaspagadas<0||nuevaventa->cuotaspagadas>10); } if(formadepago==1) { nuevaventa->cuotaspagadas=10; } //hasta aca C: nuevo->id = GeneradorId (); //aca la otra parte nuevaventa->idclie=nuevo->id; switch(tipodepa) { case 1: nuevaventa->total=20500000; break; case 2: nuevaventa->total=29500000; break; 209
case 3: nuevaventa->total=35000000; break; } if (!headventas) { headventas=nuevaventa; } else { while(headventas->sig) { headventas=headventas->sig; } headventas->sig=nuevaventa; } //hasta ac return nuevo;
} return numero; }
int coprobarDepa(struct edificio *edi,int fila,int columna,int NumDepa,int *filaOcupada, int *columnaOcupada) { int i, j ; struct edificio *tmp=edi;
} 211
} return 0; }
struct condominio * BuscarCondo(struct provincia *inicio, int *ident) { struct provincia *tmp=NULL, *aux=NULL; struct condominio *nulo=NULL; int Opcion, esta=0, esta2=0, res;
while(esta==0) { tmp=inicio;
while(tmp!=NULL) { printf(" %d) = %s ",tmp->opcion,tmp->nombre); tmp=tmp->sig; } printf("=> \n "); scanf("%d",&Opcion); aux=inicio; system("cls");
while(aux!=NULL) { 212
if(esta==0) { tmp=inicio; printf("*****OPCION INCORRECTA, INGRESE NUEVAMENTE\n ***** DESEA SEGUIR BUSCANDO ***** \n 1=SI 2=NO"); while(esta2==0) { scanf("%d",&res); if(res>2 || res<1) printf("OPCION INCORRECTA 1=SI 2=NO\n INGRESE NUEVAMENTE \n => "); else esta2=1; } if(res==1) { esta=0; 213
} } }
struct edificio * BuscarEdifi (struct condominio *inicioCondo) { struct condominio *tmp=NULL, *aux=NULL, *encontrado =NULL ; struct edificio *nulo=NULL; int Opcion, cont=1, esta=0, esta2=0;
if(encontrado) return (encontrado->edi); else if(esta==0) { tmp=inicioCondo; printf("*****OPCION INCORRECTA, INGRESE NUEVAMENTE\n ***** DESEA SEGUIR BUSCANDO ***** \n 1=SI 2=NO"); while(esta2==0) { scanf("%d",&esta2); if(esta2>2 || esta2<1) { printf("OPCION INCORRECTA 1=SI 2=NO\n INGRESE NUEVAMENTE \n => "); esta2=0; } else { esta2=1; return (nulo); } } } } }
215
char * RutaIdentCondo(int identificador) { char *rutad=NULL; switch (identificador) { case 1: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\1.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\1.txt"); return rutad; break;
case 2: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\2.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\2.txt"); return rutad; break; case 3: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\3.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\3.txt"); return rutad; break; case 4: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\4.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\4.txt"); return rutad; break; 216
case 5: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\5.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\5.txt"); return rutad; break; case 6: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\6.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\6.txt"); return rutad; break; case 7: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\7.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\7.txt"); return rutad; break; case 8: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\8.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\8.txt"); return rutad; break; case 9: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\9.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\9.txt"); return rutad; break; case 10: 217
rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\10.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\10.txt"); return rutad; break; case 11: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\11.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\11.txt"); return rutad; break; case 12: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\12.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\12.txt"); return rutad; break; case 13: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\13.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\13.txt"); return rutad; break; case 14: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\14.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\14.txt"); return rutad; break; case 15: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\15.txt")+1)); 218
strcpy(rutad,"IDSCONDOMINIOS\\15.txt"); return rutad; break; case 16: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\16.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\16.txt"); return rutad; break; case 17: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\17.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\17.txt"); return rutad; break; case 18: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\18.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\18.txt"); return rutad; break; case 19: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\19.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\19.txt"); return rutad; break; case 20: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\20.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\20.txt"); 219
return rutad; break; case 21: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\21.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\21.txt"); return rutad; break; case 22: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\22.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\22.txt"); return rutad; break; case 23: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\23.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\23.txt"); return rutad; break; case 24: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\24.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\24.txt"); return rutad; break; case 25: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\25.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\25.txt"); return rutad; 220
break; case 26: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\26.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\26.txt"); return rutad; break; case 27: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\27.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\27.txt"); return rutad; break; case 28: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\28.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\28.txt"); return rutad; break; case 29: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\29.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\29.txt"); return rutad; break; case 30: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\30.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\30.txt"); return rutad; break; 221
case 31: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\31.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\31.txt"); return rutad; break; case 32: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\32.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\32.txt"); return rutad; break; case 33: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\33.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\33.txt"); return rutad; break; case 34: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\34.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\34.txt"); return rutad; break; case 35: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\35.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\35.txt"); return rutad; break; case 36: 222
rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\36.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\36.txt"); return rutad; break; case 37: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\37.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\37.txt"); return rutad; break; case 38: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\38.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\38.txt"); return rutad; break; case 39: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\39.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\39.txt"); return rutad; break; case 40: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\40.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\40.txt"); return rutad; break; case 41: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\41.txt")+1)); 223
strcpy(rutad,"IDSCONDOMINIOS\\41.txt"); return rutad; break; case 42: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\42.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\42.txt"); return rutad; break; case 43: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\43.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\43.txt"); return rutad; break; case 44: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\44.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\44.txt"); return rutad; break; case 45: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\45.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\45.txt"); return rutad; break; case 46: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\46.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\46.txt"); 224
return rutad; break; case 47: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\47.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\47.txt"); return rutad; break; case 48: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\48.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\48.txt"); return rutad; break; case 49: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\49.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\49.txt"); return rutad; break; case 50: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\50.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\50.txt"); return rutad; break; case 51: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\51.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\51.txt"); return rutad; 225
break; case 52: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\52.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\52.txt"); return rutad; break; case 53: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\53.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\53.txt"); return rutad; break; case 54: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\54.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\54.txt"); return rutad; break; case 55: rutad = (char *)malloc(sizeof(char)* (strlen("IDSCONDOMINIOS\\55.txt")+1)); strcpy(rutad,"IDSCONDOMINIOS\\55.txt"); return rutad; break; }
{ struct pila *nuevo ; nuevo = (struct pila * )malloc(sizeof(struct pila)); nuevo->valor = valor ; nuevo->sig = *cima ; *cima = nuevo ; } struct condominio * pop (struct pila **cima) { struct pila *p; struct condominio *v;
p= *cima; if(!*cima) return NULL ; *cima = p->sig ; v = p->valor ; free(p) ; return (v); } struct condominio * preorden(struct condominio *ptr,struct cliente *Encontrado) { struct condominio *CondoClientes = NULL ; int i = 0 ; struct pila *cima = NULL ; push (&cima,NULL); 227
while(ptr) { CondoClientes = RecorridoCondo(ptr->edi,Encontrado,ptr); if(CondoClientes) return CondoClientes ; else { if(ptr->der) push(&cima,ptr->der); if(ptr->izq) ptr = ptr->izq ; else ptr = pop(&cima) ;
} return CondoClientes ; }
struct condominio *recorridoregion(struct regiones *region) { int mayornum=0,i=0; struct condominio *mayor,*comparar=NULL;
} return mayor;
while(prov!=NULL) { comparar=recorridocondominio(prov->condom,&mayor);
struct condominio *recorridocondominio(struct condominio *arbol,struct condominio **mayorencondominio) { struct condominio *mayorencondo,*comparar; mayorencondo=*mayorencondominio;
} return mayorencondo ;
} //funcion extra numero dos la cosa de los clientes void informacion_cliente(struct Sistema *head) { struct cliente *vercuantopago; 231
struct ventas * aux=head->caeza; int monto,deuda,cuotasnopagadas; vercuantopago=BuscarCliente(head); while(vercuantopago->id!=aux->idclie) { aux=aux->sig; } printf("el cliente de nombre %s \n" ,vercuantopago->nombre); monto=(aux->cuotaspagadas*(aux->total/10)); cuotasnopagadas=(10-aux->cuotaspagadas); deuda=cuotasnopagadas*(aux->total/10); if(aux->cuotaspagadas==10) { printf("el cliente no presenta deudas con la empresa"); } else { printf("lleba %d cuotas pagadas en un monto total a %d pesos\n",aux->cuotaspagadas,monto); printf("y le quedan por pagar %d cuotas que suman un monto total a %d pesos\n",cuotasnopagadas,deuda); }
int id,cuotas,total; struct ventas *headven=head->caeza; struct ventas *nuevo=NULL; struct ventas *aux; char* ventas ="ventas.txt"; FILE *fp=NULL;
aux=headven;
fp=fopen(ventas,"r"); while(!feof(fp)) {
fscanf(fp,"%i\n",&id); fscanf(fp,"%i\n",&cuotas); fscanf(fp,"%i\n",&total); nuevo=(struct ventas *)malloc(sizeof(struct ventas )); nuevo->idclie=id; nuevo->cuotaspagadas=cuotas; nuevo->total=total; if(headven=NULL) { headven=nuevo; } else{ 233
} fclose(fp); } }
void actualizar_ventas(struct Sistema *head) { char* ventas="venta.txt"; struct ventas *venta=head->caeza; FILE *fp=NULL; fp=fopen("venta.txt","w"); if(fp) { if(venta==NULL) { fclose(fp);
} else{ 234
fclose(fp);
} } else{
} }
235