Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 58.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <Validador.h>
  4. #include <windows.h>
  5. #include <time.h>
  6.  
  7. #define LENISBN     14
  8. #define LENTITULO   51
  9. #define LENEDIT     81
  10. #define LENIDAUTOR  11
  11. #define LENNOMB     41
  12. #define LENAPEL     36
  13. #define LENIDDOC    21
  14. #define LENTELEFONO 11
  15.  
  16. typedef struct
  17. {
  18.     unsigned short int dd, mm, yyy;
  19. } FECHA;
  20.  
  21. typedef struct
  22. {
  23.     char ISBN[LENISBN];
  24.     char titulo[LENTITULO];
  25.     char editora[LENEDIT];
  26.     char idautor[LENIDAUTOR];
  27.     FECHA fechaedicion;
  28.     int edicion;
  29. } LIBRO;
  30.  
  31. typedef struct
  32. {
  33.     char idautor[LENIDAUTOR];
  34.     char nombres[LENNOMB];
  35.     char apellidos[LENAPEL];
  36.     FECHA fechanacimiento;
  37. } AUTOR;
  38.  
  39. typedef struct
  40. {
  41.     char iddocumento[LENIDDOC];
  42.     char telefono[LENTELEFONO];
  43.     char nombres[LENNOMB];
  44.     char apellidos[LENAPEL];
  45. } USUARIO;
  46.  
  47. typedef struct
  48. {
  49.     char iddocumento[LENIDDOC];
  50.     char ISBN[LENISBN];
  51.     FECHA fecprestamo;
  52.     FECHA fecdevolucion;
  53.     int diasprestamo;
  54.     float recargodiario;
  55. } PRESTAMOS;
  56.  
  57. typedef struct nodoU
  58. {
  59.    USUARIO user;
  60.    struct nodoU *sig,*ant;
  61. }NODOU;
  62.  
  63. typedef struct nodoA
  64. {
  65.    AUTOR autor;
  66.    struct nodoA *sig,*ant;
  67. }NODOA;
  68.  
  69. typedef struct nodoL
  70. {
  71.    LIBRO libro;
  72.    struct nodoL* sig;
  73.    struct nodoL* ant;
  74. }NODOL;
  75.  
  76. typedef struct nodoP
  77. {
  78.    PRESTAMOS prestamos;
  79.    struct nodoP *sig,*ant;
  80. }NODOP;
  81.  
  82. // Asignacion de listas
  83. // Funciones para el usuario
  84. void nodoUSER(NODOU **,NODOU **,USUARIO  );
  85. USUARIO capuser(void);
  86. USUARIO ExisteUser(NODOU *cab, char* Busq);
  87. USUARIO capuser();
  88. int EliminarUsuario(NODOU **cabeza,NODOU **cola,int Dato);
  89.  
  90. // Funciones para el Prestamo
  91. PRESTAMOS SolicitarPrestamo(USUARIO *Infouser, LIBRO InfoLibro );
  92. void ScrollingPRESTAMO(NODOP **cab, NODOP **cola, int *n);
  93. void impuPRESTAMO(int y,NODOP  *cabactual, NODOP **cola, int CFS, int CTS, int *sel, int Num);
  94. void nodoPRESTAMO(NODOP **cab, NODOP **cola,PRESTAMOS prestamo);
  95. int EliminarPrestamo(NODOP **cabeza, NODOP **cola, int Dato);
  96.  
  97. //Funciones para el Autor
  98. int BuscarAutor(NODOA *, char *);
  99. void nodoAUTOR(NODOA **,NODOA **, AUTOR );
  100. AUTOR capautor(int );
  101. AUTOR capautor(int Nautores);
  102. int EliminarAutor(NODOA **cabeza,NODOA **cola,int Dato);
  103.  
  104. // Funciones para Libro
  105. LIBRO caplibro(NODOA *);
  106. LIBRO existeLIBRO(NODOL *cab, char *Busq);
  107. void nodoLIBRO(NODOL **, NODOL **, LIBRO);
  108. LIBRO caplibro(NODOA *cab);
  109. int EliminarLibro(NODOL **cabeza,NODOL **cola,int Dato);
  110. LIBRO existeLIBRO(NODOL *cab, char *Busq);
  111.  
  112. // Otros
  113. int Comparar(char *str1, char *str2);
  114. void Limpiar();
  115. void IDasig(char *, int);
  116. int BuscarAutor(NODOA *cab, char *busq);
  117. int ValidaFechas(int D1, int M1, int Y1, int D2, int M2, int Y2);
  118. void SeguroBorrar(char *tecla);
  119. int Comparar(char *str1, char *str2);
  120. void SeguroBorrar(char *tecla);
  121. int PalabraG(char *aux);
  122.  
  123. int main(){
  124.    
  125.    char Mensaje[CANT][LEN] = {"Libros              ",
  126.                               "Usuarios            ",
  127.                               "Autores             ",
  128.                               "Salir               "
  129.                               };
  130.    char opcionLibro[CANT][LEN] = {"Prestamo        ",
  131.                                  "Agregar Libro   ",
  132.                                  "Editar libro    ",
  133.                                  "Volver          "
  134.                                  };
  135.    char opcionUser[CANT][LEN] = {"Registrar Usuario",
  136.                                  "Editar usuario   ",
  137.                                  "Volver           "};
  138.    char opcionAutor[CANT][LEN] = {"Registrar Autor",
  139.                                  "Editar Autor   ",
  140.                                  "Volver         "};
  141.    char opcionPrestamo[CANT][LEN] = {"Solicitar Prestamo",
  142.                                       "Prestamos Actuales",
  143.                                      
  144.                                       "Volver            "};
  145.    int accion,indAutor = 0,indDoc = 1,accionLib,accionUser,accionAutor,accionPrestamo,CL=0,CU=0,CP=0,comp;
  146.    char userB[LENNOMB],libroB[LENNOMB], resp;
  147.    NODOA *cabezaA,*colaA;
  148.    cabezaA = colaA = NULL;
  149.    NODOL *cabezaL,*colaL;
  150.    cabezaL = colaL = NULL;
  151.    NODOU *cabezaU,*colaU,*nom;
  152.    cabezaU = colaU = NULL;
  153.    NODOP *cabezaP,*colaP;
  154.    cabezaP = colaP = NULL;
  155.    USUARIO userP,let = {ENTER,ENTER,ENTER,ENTER};;
  156.    LIBRO libroP,letN = {ENTER,ENTER,ENTER,ENTER,ENTER,ENTER};;
  157.    accion = Menu(Mensaje,4,40,5,LIGHTBLUE,WHITE,YELLOW,RED);
  158.    Limpiar();
  159.    while(accion != 3){
  160.    switch(accion){
  161.    case 0 :
  162.       accionLib = Menu(opcionLibro,4,40,4,LIGHTBLUE,WHITE,YELLOW,RED);
  163.       Limpiar();
  164.       switch(accionLib){
  165.          case 0 :
  166.             Limpiar();
  167.             if(CL > 0 && CU > 0){
  168.             accionPrestamo = Menu(opcionPrestamo,3,40,4,LIGHTBLUE,WHITE,YELLOW,RED);
  169.             Limpiar();
  170.             switch(accionPrestamo){
  171.             case 0 :
  172.                   Colores(WHITE,BLACK);
  173.                   gotoxy(40,4);
  174.                   printf("Introduce Informacion del usuario (Nombres,telefonos ETC).");
  175.                   CapChar(userB,1,'!',55,7,15);
  176.                   do{userP = ExisteUser(cabezaU,userB);
  177.                      comp = Comparar(userP.nombres,let.nombres);
  178.                      if(comp == 1){
  179.                         printf("\n Usuario no existe, %cDesea continuar?",168);
  180.                         do{
  181.                            resp = toupper(getch());
  182.                            if(resp == 'N'){
  183.                               comp = 2;
  184.                            }
  185.                            if(resp == 'S'){
  186.                               Colores(BLACK,BLACK);
  187.                               gotoxy(40,4);printf("\n                                                      ");
  188.                               CapChar(userB,1,'!',55,7,15);
  189.                            }
  190.                         }while(resp != 'N' && resp != 'S');
  191.                      }
  192.                   }while(comp == 1);
  193.                   if(comp != 2){
  194.                   gotoxy(60,7);
  195.                   printf("Introduce Informacion del Libro.");
  196.                   CapChar(libroB,1,'!',55,10,15);
  197.                   do{libroP = existeLIBRO(cabezaL,libroB);
  198.                      comp = Comparar(libroP.editora,letN.editora);
  199.                      if(comp == 1){
  200.                         printf("\n Libro no existe, %cDesea continuar?",168);
  201.                         do{
  202.                            resp = toupper(getch());
  203.                            if(resp == 'N'){
  204.                               comp = 2;
  205.                            }
  206.                            if(resp == 'S'){
  207.                               Colores(BLACK,BLACK);
  208.                               gotoxy(60,7);printf("\n                                                      ");
  209.                               CapChar(libroB,1,'!',55,10,15);
  210.                            }
  211.                         }while(resp != 'N' && resp != 'S');
  212.                      }
  213.                   }while(comp == 1);
  214.                if(comp != 2)
  215.                   {IDasig(userP.iddocumento,CP+1);
  216.                   nodoPRESTAMO(&cabezaP,&colaP,SolicitarPrestamo(&userP,libroP));
  217.                   CP++;
  218.                   Limpiar();
  219.                   }
  220.                }
  221.                else{
  222.                   Limpiar(); Sleep(500);
  223.                   Colores(BLACK,LIGHTRED); gotoxy(40,5);
  224.                   printf("Debes ingresar un libro primero o un usuario"); Sleep(1000);
  225.                }
  226.                break;
  227.             case 1 :
  228.                if(CP > 0){
  229.                   ScrollingPRESTAMO(&cabezaP,&colaP,&CP);
  230.                   Limpiar();}
  231.                
  232.             }
  233.             break;
  234.          }
  235.          else{
  236.                   Limpiar(); Sleep(500);
  237.                   Colores(BLACK,LIGHTRED); gotoxy(40,5);
  238.                   printf("Debes registrar un prestamo primero"); Sleep(1000);
  239.                }
  240.                break;
  241.       case 1 :
  242.          nodoLIBRO(&cabezaL,&colaL,caplibro(cabezaA));
  243.          CL++;
  244.       break;
  245.       case 2 :
  246.          if(CL > 0){
  247.             ScrollingLIBRO(&cabezaL,&colaL,&CL,cabezaA,cabezaP);
  248.             Limpiar();}
  249.          else{
  250.             Limpiar(); Sleep(500);
  251.             Colores(BLACK,LIGHTRED); gotoxy(40,5);
  252.             printf("Debes ingresar un libro primero"); Sleep(1000);
  253.          }
  254.       }
  255.       break;
  256.       case 1 :
  257.          accionUser = Menu(opcionUser,3,40,5,LIGHTBLUE,WHITE,YELLOW,RED);
  258.          Limpiar();
  259.          switch(accionUser){
  260.          case 0 :
  261.             gotoxy(45,5);
  262.             Colores(WHITE,LIGHTGRAY);
  263.             nodoUSER(&cabezaU,&colaU,capuser());
  264.             CU++;
  265.          break;
  266.          case 1 :
  267.             if(CU > 0){
  268.                ScrollingUSER(&cabezaU,&colaU,&CU,cabezaP);
  269.                Limpiar();}
  270.             else{
  271.                Limpiar(); Sleep(500);
  272.                Colores(BLACK,LIGHTMAGENTA); gotoxy(40,5);
  273.                printf("Debes ingresar un usuario primero"); Sleep(1000);
  274.             }
  275.             }
  276.          
  277.       break;
  278.       case 2 :
  279.          accionAutor = Menu(opcionAutor,3,40,5,LIGHTBLUE,WHITE,YELLOW,RED);
  280.          Limpiar();
  281.          switch(accionAutor){
  282.          case 0 :
  283.             nodoAUTOR(&cabezaA,&colaA,capautor(indAutor));
  284.             indAutor++;
  285.          break;
  286.          case 1 :
  287.             if(indAutor > 0){
  288.                ScrollingAUTOR(&cabezaA,&colaA,&indAutor,cabezaL);
  289.                Limpiar();
  290.             }
  291.             else{
  292.                Limpiar(); Sleep(500);
  293.                Colores(BLACK,YELLOW); gotoxy(40,5);
  294.                printf("Debes ingresar un autor primero"); Sleep(1000);
  295.             }
  296.          }
  297.       break;
  298.          }
  299.       Limpiar();
  300.       accion = Menu(Mensaje,4,40,5,LIGHTBLUE,WHITE,YELLOW,RED);
  301.       Limpiar();
  302.       }// while
  303.    
  304. }
  305. /// Prestamos
  306. /*
  307. Funcion: "ScrollingPrestamo"
  308. Argumento: NODOP **cab = "cabeza la lista", NODOP **cola = "Cola de la lista" int *n = "Cantidad de prestamos actuales",
  309. Es un puntero porque su valore puede modificarse.
  310. Objetivo: "Desplazar todos los prestamos actuales"
  311. Retorno: "Nada"
  312. */
  313. void ScrollingPRESTAMO(NODOP **cab, NODOP **cola, int *n){
  314.    Limpiar();
  315.    NODOP *IND,*CabezaActual;
  316.        CabezaActual = *cab;
  317.        int indy = 6,indice = 1;
  318.        char letra,teclaBorrar;
  319.        Colores(BLACK,WHITE);    
  320.       indy = 6;
  321.       int select = 0,Turno = 0,busqueda = 0;
  322.       char tecla;
  323.      
  324.       _setcursortype(0);
  325.       do{
  326.          impuPRESTAMO(indy,CabezaActual,cola,BLACK,LIGHTRED,&select,*n);
  327.          tecla = getch();
  328.  
  329.          if ( tecla == ARRIBA)
  330.          {
  331.             if(CabezaActual != *cab){
  332.             select--;
  333.             Turno--;
  334.  
  335.       }
  336.            
  337.          }
  338.  
  339.          if ( tecla == ABAJO )
  340.          {
  341.             select++;
  342.             Turno++;
  343.             if(Turno >= 4){
  344.               CabezaActual = CabezaActual->sig;
  345.               select = 3;
  346.             }
  347.             if ( Turno == *n )
  348.                {  select = 0;
  349.                   CabezaActual = *cab;
  350.                   Turno = 0;
  351.                }
  352.          }
  353.          
  354.          if(tecla == ENTER){
  355.             for (IND = *cab; IND; IND = IND->sig){
  356.                   if(busqueda == Turno){
  357.                      PagarPrestamo(cab,cola,Turno);
  358.                      EliminarPrestamo(cab,cola,Turno);
  359.                      break;
  360.                   }
  361.                   busqueda++;
  362.             }
  363.             tecla = ESP;
  364.          }
  365.       }while ( tecla != ESP && tecla != ENTER );
  366.  
  367.       if ( tecla == ESP )
  368.          select = -1;
  369. }
  370. /*
  371. Funcion: "impuPRESTAMO"
  372. Argumento: NODOP *cabactual = "Nodo que varia mediante el scrolling", NODOP **cola = "Cola de la lista, para saber su valor debe ser **",
  373.  int y = "Coordenada en el eje y, (de 6 a 9)", int CFS = "Color de fonddo seleccionado del scrolling", int CTS = "Color de texto seleccionado,
  374.  del scrolling", int *sel = "Numero de seleccion actual en el scrlling", int Num = cantidad de elementos en la lista
  375. Es un puntero porque su valore puede modificarse.
  376. Objetivo: "imprimir todos los prestamos actuales"
  377. Retorno: "Nada"
  378. */
  379. void impuPRESTAMO(int y,NODOP  *cabactual, NODOP **cola, int CFS, int CTS, int *sel, int Num){
  380.    int indice = 0,info,mayor = 25,x,cont,MayorindN=6,MayorindA = 8,MayorindT = 8,posy,mayorNAT=10;
  381.    NODOP *IND;
  382.    // Evaluar impresion tabulada
  383.    
  384.     for (IND = cabactual; IND; IND = IND->sig){
  385.     info = PalabraG(IND->prestamos.iddocumento);
  386.     if(info > mayor)
  387.     {
  388.         mayor = info;
  389.     }
  390.     if(info > mayorNAT)
  391.     {
  392.        mayorNAT = info;
  393.     }
  394.     info = PalabraG(IND->prestamos.ISBN);
  395.     if(info > mayor)
  396.     {
  397.         mayor = info;
  398.     }
  399.     if(info > mayorNAT)
  400.     {
  401.        mayorNAT = info;
  402.     }
  403.    
  404. }
  405.        for (IND = cabactual; IND; IND = IND->sig){
  406.          info = PalabraG(IND->prestamos.iddocumento);
  407.           if(info > MayorindN)
  408.           {
  409.               MayorindN = info;
  410.           }
  411.          info = PalabraG(IND->prestamos.ISBN);
  412.           if(info > MayorindA)
  413.           {
  414.               MayorindA = info;
  415.           }
  416.     }
  417.    if(cabactual != *cola){
  418.    for (IND = cabactual; IND; IND = IND->sig,indice++){
  419.          
  420.       if(y <= 9){
  421.  
  422.          // imprimir tabla
  423.          gotoxy(40,y);
  424.          if(y == 6 || y == 8)
  425.             Colores(BLUE,LIGHTCYAN);
  426.          if(y == 7 || y == 9)
  427.             Colores(LIGHTCYAN,BLUE);
  428.          if ( indice == *sel )
  429.            {Colores(CFS,CTS);}
  430.          
  431.          
  432.       x = 40;
  433.        for(cont=0; cont<mayor;cont++)
  434.        {
  435.             gotoxy(x,y);
  436.             printf(" ");
  437.            x++;
  438.        }
  439.          gotoxy(40,y);
  440.          printf("%s",IND->prestamos.iddocumento);
  441.          // evalua nombres denuevo para saber la posision del apellido
  442.          info = PalabraG(IND);
  443.          x = 41 + MayorindN;
  444.          gotoxy(x,y);
  445.          printf(" %s",IND->prestamos.ISBN);
  446.  
  447.          }
  448.       y++;
  449.       }
  450.    }
  451.    else{
  452.       for (IND = cabactual; IND; IND = IND->ant,indice++){
  453.             if(y <= 9){
  454.                   // imprimir tabla
  455.          gotoxy(40,y);
  456.          if(y == 6 || y == 8)
  457.             Colores(BLUE,LIGHTCYAN);
  458.          if(y == 7 || y == 9)
  459.             Colores(LIGHTCYAN,BLUE);
  460.          if ( indice == *sel )
  461.            {Colores(CFS,CTS);}
  462.          
  463.          
  464.       x = 40;
  465.        for(cont=0; cont<mayor;cont++)
  466.        {
  467.             gotoxy(x,y);
  468.             printf(" ");
  469.            x++;
  470.        }
  471.          gotoxy(40,y);
  472.          printf("%s",IND->prestamos.iddocumento);
  473.          x = 41 + MayorindN;
  474.          gotoxy(x,y);
  475.          printf(" %s",IND->prestamos.ISBN );
  476.          }
  477.       y++;
  478.       }
  479.    }
  480.       gotoxy(40,5);
  481.     Colores(WHITE,BLACK);
  482.     printf("USUARIO");
  483.     cont = 7;
  484.    if(MayorindN > 7)
  485.       for(cont;cont<MayorindN;cont++){
  486.          printf(" ");
  487.       }
  488.       printf("|");
  489.       x = 41 + MayorindN;
  490.       gotoxy(x,5);
  491.       printf(" ISBN");
  492.       cont = 5;
  493.       for(cont;cont<MayorindA;cont++){
  494.          printf(" ");
  495.       }
  496.       printf("|");
  497.    
  498.       return;
  499. }
  500. /*
  501. Funcion: IDasig
  502. Argumento: char *ID = "Variable a modificar con el ID", int Numemp= "Cantidad de repeticiones en funcion de elementos"
  503. Objetivo: "Asignar el ID del documento y de el autor"
  504. Retorno: "Nada"
  505. */
  506. void IDasig(char *ID, int Numemp){
  507.    int ind;
  508.    for(ind=0;ind<Numemp;){
  509.       ind++;
  510.    }
  511.    if(ind<=9){
  512.    sprintf(ID,"000000000%d%c",ind,ENTER);
  513.    }
  514.    else if(ind > 9 && ind <= 99){
  515.       sprintf(ID,"00000000%d%c",ind,ENTER);
  516.    }
  517.    else if(ind > 99 && ind <= 999 ){
  518.       sprintf(ID,"0000000%d%c",ind,ENTER);
  519.    }
  520.    else if(ind > 999 && ind <= 9999){
  521.       sprintf(ID,"000000%d%c",ind,ENTER);
  522.    }
  523.    else if(ind > 9999 && ind <= 99999){
  524.       sprintf(ID,"00000%d%c",ind,ENTER);
  525.    }
  526.    else if(ind > 99999 && ind <= 999999){
  527.       sprintf(ID,"0000%d%c",ind,ENTER);
  528.    }
  529.    else if(ind > 999999 && ind <= 9999999){
  530.       sprintf(ID,"000%d%c",ind,ENTER);
  531.    }
  532.    else if(ind > 9999999 && ind <= 99999999){
  533.       sprintf(ID,"00%d%c",ind,ENTER);
  534.    }
  535.    else if(ind > 99999999 && ind <= 999999999){
  536.       sprintf(ID,"0%d%c",ind,ENTER);
  537.    }
  538.    else if(ind > 99999999 && ind <= 999999999){
  539.       sprintf(ID,"00%d%c",ind,ENTER);
  540.    }
  541.    else if(ind > 999999999 && ind <= 9999999999){
  542.       sprintf(ID,"0%d%c",ind,ENTER);
  543.    }
  544.    else{
  545.       sprintf(ID,"%d%c",ind,ENTER);
  546.    }
  547. }
  548. /*
  549. Funcion: nodoPRESTAMO
  550. Argumento: NODOP **cab = "Cabeza que se asignara en la lista, NODOP **cola = "Cola que se modificarra en la lista"
  551. Objetivo: "Enlazar nodos en la lista en el inicio"
  552. Retorno: "Nada"
  553. */
  554. void nodoPRESTAMO(NODOP **cab, NODOP **cola,PRESTAMOS prestamo){
  555.    NODOP *Colector;
  556.    Colector = (NODOP *) malloc(sizeof(NODOP));
  557.    Colector->prestamos = prestamo;
  558.    Colector->ant = NULL;
  559.    Colector->sig = *cab;
  560.    if(*cab != NULL)
  561.       (*cab)->ant = Colector;
  562.    *cab = Colector;
  563.     return;
  564. }
  565. /*
  566. Funcion: PagarPrestamo
  567. Argumento: NODOP **cab = "Cabeza que se asignara en la lista, NODOP **cola = "Cola que se modificarra en la lista", int turno = indice de
  568. valor de empleado.
  569. Objetivo: "Enlazar nodos en la lista en el inicio"
  570. Retorno: "Nada"
  571. */
  572. void PagarPrestamo(NODOP **cab, NODOP **cola, int Turno){
  573.    int indice = 0,x = 64,y = 6,num = 0,selec,Mora = 0,cargos;
  574.    unsigned short int Dia = 0,Mes = 0,Year = 0;
  575.    char tecla;
  576.    NODOP *IND;
  577.    PRESTAMOS actual;
  578.    for(IND = *cab;IND;IND=IND->sig){
  579.       if(indice == Turno){
  580.          actual = IND->prestamos;
  581.          break;
  582.       }
  583.       indice++;
  584.       Turno++;
  585.    }
  586.    Limpiar();
  587.    gotoxy(45,5);
  588.    Colores(WHITE,BLACK);
  589.    IND = *cab;
  590.    printf("Hola: %s, seleccione libro a devolver",actual.iddocumento);
  591.     while(IND != *cola){
  592.       indice = Comparar(actual.ISBN,IND->prestamos.ISBN);
  593.       if(indice == 1){
  594.          gotoxy(x,y);
  595.          printf("%s",IND->prestamos.ISBN);
  596.          y++;
  597.       }
  598.       IND = IND->sig;
  599.       num++;
  600.     }
  601.     _setcursortype(1);
  602.     for(indice=0;indice<num;){
  603.          tecla = getch();
  604.          if(tecla == ARRIBA && indice != 0){
  605.             y--;
  606.             gotoxy(30,y);
  607.             indice--;
  608.          }
  609.          if(tecla == ABAJO && indice != num-1){
  610.             y++;
  611.             gotoxy(30,y);
  612.             indice++;
  613.          }
  614.          if(tecla == ENTER){
  615.             selec = indice;
  616.             indice = num+1;
  617.          }
  618.     }
  619.     _setcursortype(0); indice = 0;
  620.     for(IND = *cab;IND;IND=IND->sig){
  621.       if(indice == selec){
  622.          Limpiar();
  623.          Colores(WHITE,BLACK);
  624.          gotoxy(35,4);
  625.          printf("Fecha limite de pago:");
  626.          Colores(RED,BLACK);
  627.          printf("%02d/%02d/%d",IND->prestamos.fecdevolucion.dd,IND->prestamos.fecdevolucion.mm,IND->prestamos.fecdevolucion.yyy);
  628.          gotoxy(35,6);
  629.          Colores(WHITE,BLACK);
  630.          _setcursortype(1);
  631.          printf("Introduce fecha de devoluci%cn:",162);
  632.          do{
  633.             Fechas(&Dia,&Mes,&Year,65,6);
  634.          }while(ValidaFechas(Dia,Mes,Year,IND->prestamos.fecprestamo.dd,IND->prestamos.fecprestamo.mm,IND->prestamos.fecprestamo.yyy) == 2);
  635.          if(ValidaFechas(Dia,Mes,Year,IND->prestamos.fecdevolucion.dd,IND->prestamos.fecdevolucion.mm,IND->prestamos.fecdevolucion.yyy) == 1){
  636.             for(indice=IND->prestamos.fecdevolucion.dd;Mora<IND->prestamos.diasprestamo;){
  637.                Mora++;
  638.                cargos = Mora * 10;
  639.             }
  640.             gotoxy(35,7); Colores(YELLOW,LIGHTRED);
  641.             printf("Entrega tarde, Cargos por mora: %d",cargos);
  642.          }
  643.          gotoxy(35,8);
  644.          Colores(WHITE,LIGHTGREEN);
  645.          printf("Prestamo pagado, libro devuelto :)");
  646.          tecla = getch();
  647.          break;
  648.       }
  649.       indice++;
  650.     }
  651.  
  652. }
  653. /*
  654. Funcion: EliminarPrestamo
  655. Argumento: NODOA **cabeza = "Cabeza que se asignara en la lista, NODOA **colaola = "Cola que se modificarra en la lista", int Dato = " Opcion
  656. De prestamo registrada,
  657. autor que se unira a la lista.
  658. Objetivo: "Eliminar prestamo pagado"
  659. Retorno: "Nada"
  660. */
  661. int EliminarPrestamo(NODOP **cabeza, NODOP **cola, int Dato){
  662.    NODOP *actual = *cabeza,*anteriot,*siguiente;
  663.     char *NomBuscar;
  664.     NomBuscar = (char *)malloc(sizeof(char));
  665.     int indice = 0;
  666.  
  667.    
  668.     while(actual != NULL)
  669.     {
  670.         if(indice == Dato)
  671.         {
  672.             if( actual == *cabeza)
  673.             {
  674.                *cabeza = actual->sig;
  675.                
  676.             }
  677.             else if( actual->sig == NULL)
  678.             {
  679.                 anteriot = actual->ant;
  680.                 *cola = anteriot;
  681.                 anteriot->sig = NULL;
  682.             }
  683.             else
  684.             {
  685.                 anteriot = actual->ant;
  686.                 actual->ant = NULL;
  687.                 siguiente = actual->sig;
  688.                 actual->sig = NULL;
  689.                 anteriot->sig = siguiente;
  690.                 siguiente->ant = anteriot;
  691.                
  692.             }
  693.             free(actual);
  694.             return 1;
  695.       }
  696.  
  697.     }
  698. }
  699. /// usuario                                                                                      
  700.  
  701. /*
  702. Funcion: nodoUSER
  703. Argumento: NODOU **cab = "Cabeza que se asignara en la lista, NODOU **cola = "Cola que se modificarra en la lista", USUARIO usuario ,
  704. Usuario que se unira a la lista.
  705. Objetivo: "Enlazar nodos en la lista en el inicio"
  706. Retorno: "Nada"
  707. */
  708. void nodoUSER(NODOU **cab,NODOU **cola,USUARIO usuario)
  709. {
  710.    NODOU *lector;
  711.    //FILE *UsuarioF;
  712.    //UsuarioF = fopen("C:\\Users\\r_rok\\Desktop\\Biblioteca\\Archivos.dat","ab");
  713.    lector = (NODOU *) malloc(sizeof(NODOU));
  714.    lector->user = usuario;
  715.    lector->ant = NULL;
  716.    lector->sig = *cab;
  717.    if(*cab != NULL)
  718.       (*cab)->ant = lector;
  719.    *cab = lector;
  720.     return;
  721.    
  722.    /*fwrite(lector,sizeof(USUARIO),sizeof(USUARIO),UsuarioF);
  723.    fclose(UsuarioF);*/
  724.    
  725. }
  726. /*
  727. Funcion: capuser
  728. Argumento: ninguno
  729. Objetivo: "Crear nuveo usuario a la estructura"
  730. Retorno: "Un nuevo usuario"
  731. */
  732. USUARIO capuser(){
  733.    USUARIO user;
  734.   // user = (USUARIO *) malloc(sizeof(USUARIO));
  735.    
  736.    strcpy(user.iddocumento," ");
  737.    printf("Nombre");
  738.    CapChar(&user.nombres,1,'A',42,7,15);
  739.    gotoxy(45,7);
  740.    Colores(WHITE,LIGHTGRAY);
  741.    printf("Apellido");
  742.    CapChar(&user.apellidos,1,'A',42,9,15 );
  743.    gotoxy(45,9);
  744.    Colores(WHITE,LIGHTGRAY);
  745.    printf("Telefono");
  746.    CapChar(&user.telefono,1,'8',42,11,15 );
  747.    return user;
  748. }
  749.  
  750.  
  751. void ScrollingUSER(NODOU **cab, NODOU **cola, int *n, NODOP *cabezaP)
  752. {
  753.     NODOU *IND,*CabezaActual;
  754.     NODOP *INDP;
  755.     CabezaActual = *cab;
  756.     int indy = 6,indice = 1;
  757.     char letra,teclaBorrar;
  758.     Colores(BLACK,WHITE);    
  759.    indy = 6;
  760.    int select = 0,Turno = 0,busqueda = 0,res;
  761.    char tecla;
  762.    
  763.    _setcursortype(0);
  764.    do{
  765.       impusuario(indy,CabezaActual,cola,YELLOW,BLACK,&select,*n);
  766.       tecla = getch();
  767.  
  768.       if ( tecla == ARRIBA)
  769.       {
  770.          if(CabezaActual != *cab){
  771.          select--;
  772.          Turno--;
  773.    }
  774.          
  775.       }
  776.  
  777.       if ( tecla == ABAJO )
  778.       {
  779.          select++;
  780.          Turno++;
  781.          if(Turno >= 4){
  782.            CabezaActual = CabezaActual->sig;
  783.            select = 3;
  784.          }
  785.          if ( Turno == *n )
  786.             {  select = 0;
  787.                CabezaActual = *cab;
  788.                Turno = 0;
  789.             }
  790.       }
  791.      
  792.       if(tecla == BORRAR){
  793.          for(IND = *cab;IND;IND = IND->sig){
  794.             if(busqueda == Turno)
  795.             {     for(INDP=cabezaP;INDP;INDP = INDP->sig){
  796.                         res = Comparar(IND->user.nombres,INDP->prestamos.iddocumento);
  797.                         if(res == 1){
  798.                            break;
  799.                         }
  800.                      }
  801.                   break;
  802.             }
  803.            busqueda++;
  804.          }
  805.          if(res != 1){
  806.             SeguroBorrar(&teclaBorrar);
  807.             if(teclaBorrar == 's'){
  808.                EliminarUsuario(cab,cola,Turno);
  809.                (*n)--;
  810.                tecla = ESP;
  811.             }
  812.          }
  813.          else if(res == 1){
  814.             gotoxy(40,15);
  815.             Colores(WHITE,LIGHTRED);
  816.             printf("El usuario tiene un prestamo...");
  817.             Sleep(1500);
  818.             gotoxy(40,15); Colores(BLACK,BLACK);
  819.             printf("                                  ");
  820.            
  821.          }
  822.       }
  823.       if(tecla == ENTER){
  824.          for (IND = *cab; IND; IND = IND->sig){
  825.                if(busqueda == Turno){
  826.                   EditorUSER(cab,cola,&IND);
  827.                   break;
  828.                }
  829.                busqueda++;
  830.          }
  831.          tecla = ESP;
  832.       }
  833.    }while ( tecla != ESP && tecla != ENTER );
  834.  
  835.    if ( tecla == ESP )
  836.       select = -1;
  837.    
  838. }
  839.  
  840.  
  841. void impusuario(int y,NODOU *cabactual, NODOU **cola, int CFS, int CTS, int *sel, int Num)
  842. {
  843.    int indice = 0,info,mayor = 25,x,cont,MayorindN=6,MayorindA = 8,MayorindT = 8,posy,mayorNAT=10,ind2;
  844.    NODOU *IND;
  845.    // Evaluar impresion tabulada
  846.    
  847.     for (IND = cabactual; IND; IND = IND->sig){
  848.     info = PalabraG(IND->user.nombres);
  849.     if(info > mayor)
  850.     {
  851.         mayor = info;
  852.     }
  853.     if(info > mayorNAT)
  854.     {
  855.        mayorNAT = info;
  856.     }
  857.     info = PalabraG(IND->user.apellidos);
  858.     if(info > mayor)
  859.     {
  860.         mayor = info;
  861.     }
  862.     if(info > mayorNAT)
  863.     {
  864.        mayorNAT = info;
  865.     }
  866.     info = PalabraG(IND->user.telefono);
  867.     if(info > mayor)
  868.     {
  869.         mayor = info;
  870.     }
  871.    
  872. }
  873.        for (IND = cabactual; IND; IND = IND->sig){
  874.          info = PalabraG(IND->user.nombres);
  875.           if(info > MayorindN)
  876.           {
  877.               MayorindN = info;
  878.           }
  879.          info = PalabraG(IND->user.apellidos);
  880.           if(info > MayorindA)
  881.           {
  882.               MayorindA = info;
  883.           }
  884.           info = PalabraG(IND->user.telefono);
  885.           if(info > MayorindT)
  886.           {
  887.               MayorindT = info;
  888.           }
  889.     }
  890.    if(cabactual != *cola){
  891.    for (IND = cabactual; IND; IND = IND->sig,indice++){
  892.          
  893.       if(y <= 9){
  894.  
  895.          // imprimir tabla
  896.          gotoxy(40,y);
  897.          if(y == 6 || y == 8)
  898.             Colores(BLUE,LIGHTCYAN);
  899.          if(y == 7 || y == 9)
  900.             Colores(LIGHTCYAN,BLUE);
  901.          if ( indice == *sel )
  902.            {Colores(CFS,CTS);}
  903.          
  904.          
  905.       x = 40;
  906.        for(cont=0; cont<mayor;cont++)
  907.        {
  908.             gotoxy(x,y);
  909.             printf(" ");
  910.            x++;
  911.        }
  912.          gotoxy(40,y);
  913.          for(ind2=0;ind2<MayorindN;ind2++)
  914.             printf("%c",IND->user.nombres[ind2]);
  915.          // evalua nombres denuevo para saber la posision del apellido
  916.          info = PalabraG(IND->user.nombres);
  917.          x = 41 + MayorindN;
  918.          gotoxy(x,y);
  919.          for(ind2=0;ind2<MayorindA;ind2++)
  920.             printf("%c",IND->user.apellidos[ind2]);
  921.          gotoxy(x+MayorindA+1,y);
  922.          for(ind2=0;ind2<MayorindT;ind2++)
  923.             printf("%c",IND->user.telefono[ind2]);
  924.          }
  925.       y++;
  926.       }
  927.    }
  928.    else{
  929.       for (IND = cabactual; IND; IND = IND->ant,indice++){
  930.             if(y <= 9){
  931.                   // imprimir tabla
  932.          gotoxy(40,y);
  933.          if(y == 6 || y == 8)
  934.             Colores(BLUE,LIGHTCYAN);
  935.          if(y == 7 || y == 9)
  936.             Colores(LIGHTCYAN,BLUE);
  937.          if ( indice == *sel )
  938.            {Colores(CFS,CTS);}
  939.          
  940.          
  941.       x = 40;
  942.        for(cont=0; cont<mayor;cont++)
  943.        {
  944.             gotoxy(x,y);
  945.             printf(" ");
  946.            x++;
  947.        }
  948.          gotoxy(40,y);
  949.          for(ind2=0;ind2<MayorindN;ind2++)
  950.             printf("%c",IND->user.nombres[ind2]);
  951.          // evalua nombres denuevo para saber la posision del apellido
  952.          info = PalabraG(IND->user.nombres);
  953.          x = 41 + MayorindN;
  954.          gotoxy(x,y);
  955.          for(ind2=0;ind2<MayorindA;ind2++)
  956.             printf("%c",IND->user.apellidos[ind2]);
  957.          gotoxy(x+MayorindA+2,y);
  958.          for(ind2=0;ind2<MayorindT;ind2++)
  959.             printf("%c",IND->user.telefono[ind2]);
  960.          }
  961.       y++;  
  962.       }
  963.    }
  964.       gotoxy(40,5);
  965.     Colores(WHITE,BLACK);
  966.     printf("NOMBRE");
  967.     cont = 6;
  968.    if(MayorindN > 6)
  969.       for(cont;cont<MayorindN;cont++){
  970.          printf(" ");
  971.       }
  972.       printf("|");
  973.       x = 41 + MayorindN;
  974.       gotoxy(x,5);
  975.       printf(" APELLIDO");
  976.       cont = 8;
  977.       for(cont;cont<MayorindA;cont++){
  978.          printf(" ");
  979.       }
  980.       printf("|");
  981.      
  982.       if(MayorindA > 8 || MayorindN > 6){
  983.          x = 56 + MayorindA;}
  984.       else{
  985.          x = 57;
  986.       }
  987.       gotoxy(x,5);
  988.       printf(" Telefono ");
  989.    
  990.       return;
  991. }
  992. /*
  993. Funcion: Eliminarusuario
  994. Argumento: NODOA **cabeza = "Cabeza que se asignara en la lista, NODOA **colaola = "Cola que se modificarra en la lista", int Dato = " Opcion
  995. De prestamo registrada,
  996. autor que se unira a la lista.
  997. Objetivo: "Eliminar usuario seleccionado"
  998. Retorno: "Nada"
  999. */
  1000. int EliminarUsuario(NODOU **cabeza,NODOU **cola,int Dato)
  1001. {
  1002.     NODOU *actual = *cabeza,*anteriot,*siguiente;
  1003.    
  1004.     int indice = 0;
  1005.     while(actual != NULL)
  1006.     {
  1007.         if(indice == Dato)
  1008.         {
  1009.             if( actual == *cabeza)
  1010.             {
  1011.                *cabeza = actual->sig;
  1012.                
  1013.             }
  1014.             else if( actual->sig == NULL)
  1015.             {
  1016.                 anteriot = actual->ant;
  1017.                 *cola = anteriot;
  1018.                 anteriot->sig = NULL;
  1019.             }
  1020.             else
  1021.             {
  1022.                 anteriot = actual->ant;
  1023.                 actual->ant = NULL;
  1024.                 siguiente = actual->sig;
  1025.                 actual->sig = NULL;
  1026.                 anteriot->sig = siguiente;
  1027.                 siguiente->ant = anteriot;
  1028.                
  1029.             }
  1030.             free(actual);
  1031.             return 1;
  1032.         }
  1033.         actual = actual->sig;
  1034.         indice++;
  1035.     }
  1036.     return 0;
  1037. }
  1038.  
  1039. void EditorUSER(NODOU **cabeza,NODOU **cola,NODOU **actual){
  1040.  
  1041.             Limpiar();
  1042.             gotoxy(15,2);
  1043.             Colores(WHITE,RED);
  1044.             printf("Presione (ENTER) si no desea editar nada\n (Espacio en las fechas)");
  1045.             gotoxy(25,4);
  1046.                   Colores(WHITE,BLACK);
  1047.                   printf("Nombre: ");
  1048.                   gotoxy(70,3); Colores(LIGHTGRAY,BLACK);
  1049.                   printf("Apellido: ");
  1050.                   gotoxy(60,9); Colores(LIGHTGRAY,BLACK);
  1051.                   printf("Telefono");
  1052.                  
  1053.                   // Primer nombre
  1054.                   gotoxy(25,4);
  1055.                   Colores(WHITE,BLACK);
  1056.                   printf("Nombre: ");
  1057.                   CapChar((*actual)->user.nombres,1,'A',40,7,16);
  1058.  
  1059.                   // Apellido
  1060.                   gotoxy(70,3); Colores(WHITE,BLACK);
  1061.                   printf("Apellido: ");
  1062.                   CapChar((*actual)->user.apellidos,1,'A',85,7,16);
  1063.                  
  1064.                   // Telefono
  1065.                   gotoxy(60,9); Colores(WHITE,BLACK);
  1066.                   printf("Telefono");
  1067.                   CapChar((*actual)->user.telefono,1,'3',70,12,16);
  1068.                
  1069.      
  1070.  
  1071. }
  1072.  
  1073. USUARIO ExisteUser(NODOU *cab, char* Busq){
  1074.    NODOU *IND;
  1075.    USUARIO Encontrado,Ninguno = {ENTER,ENTER,ENTER,ENTER};
  1076.    int result;
  1077.    for(IND=cab;IND;IND=IND->sig){
  1078.       Encontrado = IND->user;
  1079.       result = Comparar(IND->user.apellidos,Busq);
  1080.       if(result == 1){
  1081.          Encontrado = IND->user;
  1082.          return Encontrado;
  1083.       }
  1084.       result = Comparar(IND->user.iddocumento,Busq) ;
  1085.       if(result == 1){
  1086.          Encontrado = IND->user;
  1087.          return Encontrado;
  1088.       }
  1089.       result = Comparar(IND->user.nombres,Busq);
  1090.       if(result == 1){
  1091.          Encontrado = IND->user;
  1092.          return Encontrado;
  1093.       }
  1094.       result = Comparar(IND->user.telefono,Busq);
  1095.       if(result == 1){
  1096.          Encontrado = IND->user;
  1097.          return Encontrado;
  1098.       }
  1099.    }
  1100.    return Ninguno;
  1101. }
  1102.  
  1103. /// Autor                                                                                        
  1104.  
  1105. /*
  1106. Funcion: nodoAUTOR
  1107. Argumento: NODOA **cab = "Cabeza que se asignara en la lista, NODOA **cola = "Cola que se modificarra en la lista", AUTOR autor,
  1108. autor que se unira a la lista.
  1109. Objetivo: "Enlazar nodos en la lista en el inicio"
  1110. Retorno: "Nada"
  1111. */
  1112. void nodoAUTOR(NODOA **cab,NODOA **cola, AUTOR autor){
  1113.    NODOA *creador;
  1114.    creador = (NODOA *) malloc(sizeof(NODOA));
  1115.    creador->autor = autor;
  1116.    creador->ant = NULL;
  1117.    creador->sig = *cab;
  1118.    if(*cab != NULL)
  1119.       (*cab)->ant = creador;
  1120.    *cab = creador;
  1121.       return;
  1122. }
  1123.  
  1124. /*
  1125. Funcion: capautor
  1126. Argumento: int Nautores = "Cantidad de autores actuales para asignat el nuevo ID del autor"
  1127. Objetivo: "obtenet datos para los  Autores"
  1128. Retorno: "Un nuevo Autor"
  1129. */
  1130. AUTOR capautor(int Nautores){
  1131.    AUTOR autor;
  1132.    IDasig(&autor.idautor,Nautores+1);
  1133.    Colores(WHITE,BLACK);
  1134.    gotoxy(43,2);
  1135.    printf("ID");
  1136.    gotoxy(39,3);
  1137.    printf(autor.idautor);
  1138.    gotoxy(45,5);
  1139.    Colores(WHITE,LIGHTGRAY);
  1140.    printf("Nombre");
  1141.    CapChar(&autor.nombres,1,'A',42,7,15);
  1142.    gotoxy(45,7);
  1143.    Colores(WHITE,LIGHTGRAY);
  1144.    printf("Apellido");
  1145.    CapChar(&autor.apellidos,1,'A',42,9,15 );
  1146.    gotoxy(45,9);
  1147.    Colores(WHITE,LIGHTGRAY);
  1148.    printf("Fecha de nacimiento");
  1149.    autor.fechanacimiento.dd = 0;
  1150.    autor.fechanacimiento.mm = 0;
  1151.    autor.fechanacimiento.yyy = 0;
  1152.    do{
  1153.    Fechas(&autor.fechanacimiento.dd,&autor.fechanacimiento.mm,&autor.fechanacimiento.yyy,30,9);
  1154.    }while(autor.fechanacimiento.yyy > 1999);
  1155.    return autor;
  1156. }
  1157.  
  1158.  
  1159. void ScrollingAUTOR(NODOA **cab, NODOA **cola, int *n, NODOL *cabezaL)
  1160. {
  1161.     NODOA *IND,*CabezaActual;
  1162.     NODOL *INDL;
  1163.  
  1164.     CabezaActual = *cab;
  1165.     int indy = 6,indice = 1,busqueda=0,res;
  1166.     char letra,teclaBorrar;
  1167.     Colores(BLACK,WHITE);
  1168.    
  1169.    indy = 6;
  1170.    int select = 0,Turno = 0;
  1171.    char tecla;
  1172.    
  1173.    _setcursortype(0);
  1174.    do{
  1175.       impautor(indy,CabezaActual,cola,YELLOW,BLACK,&select,*n,Turno);
  1176.       tecla = getch();
  1177.  
  1178.       if ( tecla == ARRIBA)
  1179.       {
  1180.          if(CabezaActual != *cab){
  1181.             select--;
  1182.             Turno--;
  1183.    }
  1184.          
  1185.       }
  1186.  
  1187.       if ( tecla == ABAJO )
  1188.       {
  1189.          select++;
  1190.          Turno++;
  1191.          if(Turno >= 4){
  1192.            CabezaActual = CabezaActual->sig;
  1193.            select = 3;
  1194.          }
  1195.          if ( Turno == *n )
  1196.             {  select = 0;
  1197.                CabezaActual = *cab;
  1198.                Turno = 0;
  1199.             }
  1200.       }
  1201.      
  1202.       if(tecla == BORRAR){
  1203.          for(IND = *cab;IND;IND = IND->sig){
  1204.             if(busqueda == Turno)
  1205.             {     for(INDL=cabezaL;INDL;INDL = INDL->sig){
  1206.                         res = Comparar(IND->autor.idautor,INDL->libro.idautor);
  1207.                         if(res == 1){
  1208.                            break;
  1209.                         }
  1210.                      }
  1211.                   break;
  1212.             }
  1213.            busqueda++;
  1214.          }
  1215.          if(res != 1){
  1216.             SeguroBorrar(&teclaBorrar);
  1217.             if(teclaBorrar == 's'){
  1218.                EliminarAutor(cab,cola,Turno);
  1219.                (*n)--;
  1220.                tecla = ESP;
  1221.             }
  1222.          }
  1223.          else if(res == 1){
  1224.             gotoxy(40,15);
  1225.             Colores(WHITE,LIGHTRED);
  1226.             printf("El autor esta asignado a un libro...");
  1227.             Sleep(1500);
  1228.             gotoxy(40,15); Colores(BLACK,BLACK);
  1229.             printf("                                      ");
  1230.            
  1231.          }
  1232.       }
  1233.         if(tecla == ENTER)
  1234.         {
  1235.             for (IND = *cab; IND; IND = IND->sig)
  1236.             {
  1237.                 if(busqueda == Turno)
  1238.                 {
  1239.                     EditorAUTOR(cab,cola,&IND);
  1240.                     IND = cola;
  1241.                
  1242.                 busqueda++;
  1243.             }
  1244.             }
  1245.             tecla = ESP;
  1246.         }
  1247.    }while ( tecla != ESP && tecla != ENTER );
  1248.  
  1249.    if ( tecla == ESP )
  1250.       select = -1;
  1251.    
  1252. }
  1253.  
  1254.  
  1255. void impautor(int y,NODOA *cabactual, NODOA **cola, int CFS, int CTS, int *sel, int Num, int Pfalsos)
  1256. {
  1257.     int indice = 0,info,mayor = 25,x,cont,MayorindN=6,MayorindA = 8,MayorindT = 8,posy,mayorNAT=10,ind2;
  1258.    NODOA *IND;
  1259.    // Evaluar impresion tabulada
  1260.    
  1261.     for (IND = cabactual; IND; IND = IND->sig){
  1262.     info = PalabraG(IND->autor.nombres);
  1263.     if(info > mayor)
  1264.     {
  1265.         mayor = info;
  1266.     }
  1267.     if(info > mayorNAT)
  1268.     {
  1269.        mayorNAT = info;
  1270.     }
  1271.     info = PalabraG(IND->autor.apellidos);
  1272.     if(info > mayor)
  1273.     {
  1274.         mayor = info;
  1275.     }
  1276.     if(info > mayorNAT)
  1277.     {
  1278.        mayorNAT = info;
  1279.     }
  1280.  
  1281.    
  1282. }
  1283.        for (IND = cabactual; IND; IND = IND->sig){
  1284.          info = PalabraG(IND->autor.nombres);
  1285.           if(info > MayorindN)
  1286.           {
  1287.               MayorindN = info;
  1288.           }
  1289.          info = PalabraG(IND->autor.apellidos);
  1290.           if(info > MayorindA)
  1291.           {
  1292.               MayorindA = info;
  1293.           }
  1294.  
  1295.     }
  1296.    if(cabactual != *cola){
  1297.    for (IND = cabactual; IND; IND = IND->sig,indice++){
  1298.          
  1299.       if(y <= 9){
  1300.  
  1301.          // imprimir tabla
  1302.          gotoxy(40,y);
  1303.          if(y == 6 || y == 8)
  1304.             Colores(GREEN,BLACK);
  1305.          if(y == 7 || y == 9)
  1306.             Colores(LIGHTGREEN,BLACK);
  1307.          if ( indice == *sel )
  1308.            {Colores(CFS,CTS);}
  1309.          
  1310.          
  1311.       x = 40;
  1312.        for(cont=0; cont<mayor;cont++)
  1313.        {
  1314.             gotoxy(x,y);
  1315.             printf(" ");
  1316.            x++;
  1317.        }
  1318.          gotoxy(40,y);
  1319.          for(ind2=0;ind2<MayorindN;ind2++)
  1320.             printf("%c",IND->autor.nombres[ind2]);
  1321.          // evalua nombres denuevo para saber la posision del apellido
  1322.          info = PalabraG(IND->autor.nombres);
  1323.          x = 41 + MayorindN;
  1324.          gotoxy(x,y);
  1325.          for(ind2=0;ind2<MayorindA;ind2++)
  1326.          printf("%c",IND->autor.apellidos[ind2]);
  1327.          info = PalabraG(IND->autor.apellidos);
  1328.          gotoxy(x+MayorindA+1,y);
  1329.          printf(" %02d/%02d/%d",IND->autor.fechanacimiento.dd,IND->autor.fechanacimiento.mm,IND->autor.fechanacimiento.yyy);
  1330.          }
  1331.       y++;
  1332.       }
  1333.    }
  1334.    else{
  1335.       for (IND = cabactual; IND; IND = IND->ant,indice++){
  1336.             if(y <= 9){
  1337.                   // imprimir tabla
  1338.          gotoxy(40,y);
  1339.          if(y == 6 || y == 8)
  1340.             Colores(BLUE,LIGHTCYAN);
  1341.          if(y == 7 || y == 9)
  1342.             Colores(LIGHTCYAN,BLUE);
  1343.          if ( indice == *sel )
  1344.            {Colores(CFS,CTS);}
  1345.          
  1346.          
  1347.       x = 40;
  1348.        for(cont=0; cont<mayor;cont++)
  1349.        {
  1350.             gotoxy(x,y);
  1351.             printf(" ");
  1352.            x++;
  1353.        }
  1354.          gotoxy(40,y);
  1355.          for(ind2=0;ind2<MayorindN;ind2++)
  1356.             printf("%c",IND->autor.nombres[ind2]);
  1357.          // evalua nombres denuevo para saber la posision del apellido
  1358.          info = PalabraG(IND->autor.nombres);
  1359.          x = 41 + MayorindN;
  1360.          gotoxy(x,y);
  1361.          for(ind2=0;ind2<MayorindA;ind2++)
  1362.          printf("%c",IND->autor.apellidos[ind2]);
  1363.          info = PalabraG(IND->autor.apellidos);
  1364.          printf("   %02d/%02d/%d",IND->autor.fechanacimiento.dd,IND->autor.fechanacimiento.mm,IND->autor.fechanacimiento.yyy);
  1365.          }
  1366.       y++;
  1367.       }
  1368.    }
  1369.       gotoxy(40,5);
  1370.     Colores(WHITE,BLACK);
  1371.     printf("NOMBRE");
  1372.     cont = 6;
  1373.    if(MayorindN > 6)
  1374.       for(cont;cont<MayorindN;cont++){
  1375.          printf(" ");
  1376.       }
  1377.       printf("|");
  1378.       x = 41 + MayorindN;
  1379.       gotoxy(x,5);
  1380.       printf(" APELLIDO");
  1381.       cont = 8;
  1382.       for(cont;cont<MayorindA;cont++){
  1383.          printf(" ");
  1384.       }
  1385.       printf("|");
  1386.       if(MayorindN > 6 || MayorindA > 8){
  1387.          x = 42+mayorNAT+MayorindA;}
  1388.       else{
  1389.          x = 56;
  1390.       }
  1391.       if(MayorindA > 8 || MayorindN > 6){
  1392.          x = 56 + MayorindA;}
  1393.       else{
  1394.          x = 57;
  1395.       }
  1396.       gotoxy(x,5);
  1397.       printf(" NACIMIENTO ");
  1398.    
  1399.       return;
  1400. }
  1401.  
  1402. void EditorAUTOR(NODOA **cabeza,NODOA **cola,NODOA **actual){
  1403.             unsigned short int Dia,Mes,year;
  1404.             Limpiar();
  1405.             gotoxy(15,2);
  1406.             Colores(WHITE,RED);
  1407.             printf("Presione (ENTER) si no desea editar nada\n (Espacio en las fechas)");
  1408.             gotoxy(25,4);
  1409.                   Colores(WHITE,BLACK);
  1410.                   printf("Nombre: ");
  1411.                   gotoxy(70,3); Colores(LIGHTGRAY,BLACK);
  1412.                   printf("Apellido: ");
  1413.                   gotoxy(60,9); Colores(LIGHTGRAY,BLACK);
  1414.                   printf("Fecha De nacimiento");
  1415.                  
  1416.                   // Primer nombre
  1417.                   gotoxy(25,4);
  1418.                   Colores(WHITE,BLACK);
  1419.                   printf("Nombre: ");
  1420.                   CapChar((*actual)->autor.nombres,1,'A',40,7,16);
  1421.  
  1422.                   // Apellido
  1423.                   gotoxy(70,3); Colores(WHITE,BLACK);
  1424.                   printf("Apellido: ");
  1425.                   CapChar((*actual)->autor.apellidos,1,'A',85,7,16);
  1426.                  
  1427.                   // Telefono
  1428.                   gotoxy(60,9); Colores(WHITE,BLACK);
  1429.                   printf("Fecha De nacimiento");
  1430.                   Fechas(&Dia,&Mes,&year,60,10);
  1431.                   (*actual)->autor.fechanacimiento.dd = Dia;
  1432.                   (*actual)->autor.fechanacimiento.mm = Mes;
  1433.                   (*actual)->autor.fechanacimiento.yyy = year;
  1434.      
  1435.  
  1436. }
  1437.  
  1438.  
  1439. int EliminarAutor(NODOA **cabeza,NODOA **cola,int Dato)
  1440. {
  1441.      NODOA *actual = *cabeza,*anteriot,*siguiente;
  1442.     char *NomBuscar;
  1443.     NomBuscar = (char *)malloc(sizeof(char));
  1444.     int indice = 0;
  1445.  
  1446.    
  1447.     while(actual != NULL)
  1448.     {
  1449.         if(indice == Dato)
  1450.         {
  1451.             if( actual == *cabeza)
  1452.             {
  1453.                *cabeza = actual->sig;
  1454.                
  1455.             }
  1456.             else if( actual->sig == NULL)
  1457.             {
  1458.                 anteriot = actual->ant;
  1459.                 *cola = anteriot;
  1460.                 anteriot->sig = NULL;
  1461.             }
  1462.             else
  1463.             {
  1464.                 anteriot = actual->ant;
  1465.                 actual->ant = NULL;
  1466.                 siguiente = actual->sig;
  1467.                 actual->sig = NULL;
  1468.                 anteriot->sig = siguiente;
  1469.                 siguiente->ant = anteriot;
  1470.                
  1471.             }
  1472.             free(actual);
  1473.             return 1;
  1474.         }
  1475.         actual = actual->sig;
  1476.         indice++;
  1477.     }
  1478.     return 0;
  1479. }
  1480.  
  1481. /// Libro                                                                                        
  1482.  
  1483. /*
  1484. Funcion: nodoLIBRO
  1485. Argumento: NODOA **cab = "Cabeza que se asignara en la lista, NODOA **cola = "Cola que se modificarra en la lista", LIBRO libro,
  1486. libro que se unira a la lista.
  1487. Objetivo: "Enlazar nodos en la lista en el inicio"
  1488. Retorno: "Nada"
  1489. */
  1490. void nodoLIBRO(NODOL **cab, NODOL **cola, LIBRO libro){
  1491.    NODOL *livre;
  1492.    //FILE *Libro;
  1493.    //Libro = fopen("C:\\Users\\r_rok\\Desktop\\Biblioteca\\Archivos.dat","ab");
  1494.     livre = (NODOL *) malloc(sizeof(NODOL));
  1495.       livre->libro = libro;
  1496.        livre->ant = NULL;
  1497.        livre->sig = *cab;
  1498.        if(*cab != NULL)
  1499.            (*cab)->ant = livre;
  1500.        *cab = livre;
  1501.        return;
  1502.    
  1503.    /*fwrite(livre,sizeof(LIBRO),sizeof(LIBRO),Libro);
  1504.    fclose(Libro);*/
  1505.  
  1506. }
  1507.  
  1508.  
  1509. /*
  1510. Funcion: capLIBRO
  1511. Argumento: NODOA *cab = "Cabeza que se asignara en la lista del autor para identificar el ID
  1512. Objetivo: "obtenet datos para los libros"
  1513. Retorno: "Un nuevo Libro"
  1514. */
  1515. LIBRO caplibro(NODOA *cab){
  1516.    LIBRO livre;
  1517.    char idAutor[LENIDAUTOR],resp = 'n';
  1518.    int Busqueda;
  1519.    Colores(WHITE,BLACK);
  1520.    gotoxy(45,4);
  1521.    printf("ISBN");
  1522.    CapChar(&livre.ISBN,1,'7',42,6,15);
  1523.    gotoxy(45,7);
  1524.    printf("Titulo");
  1525.    CapChar(&livre.titulo,1,'!',42,9,15);
  1526.    gotoxy(45,9);
  1527.    printf("ID del autor (si no tiene precione ENTER)");
  1528.    do{
  1529.       CapChar(idAutor,1,'5',42,11,16);
  1530.       Busqueda = BuscarAutor(cab,idAutor);
  1531.       if(idAutor[0] == '\r'){
  1532.          Busqueda = 2;
  1533.       }
  1534.       if(Busqueda == 1){
  1535.          gotoxy(45,3);
  1536.          Colores(WHITE,LIGHTGREEN);
  1537.          printf("ID asignado de forma correcta");
  1538.          strcpy(livre.idautor,idAutor);
  1539.          Sleep(1000); gotoxy(45,3); Colores(BLACK,BLACK);
  1540.          printf("                               ");
  1541.       }
  1542.       else if(Busqueda == 0){
  1543.          gotoxy(45,3);Colores(WHITE,LIGHTGREEN);
  1544.          printf("ID no existe, %cdesea ingresar otro? Si o No",168);
  1545.          do{
  1546.                resp = toupper(getch());
  1547.                if(resp == 'N'){
  1548.                   Busqueda = 2;
  1549.                }
  1550.          }while(resp != 'N' && resp != 'S');
  1551.          gotoxy(45,3);Colores(BLACK,BLACK);
  1552.          printf("                                                ");
  1553.          
  1554.       }
  1555.    }while(Busqueda == 0);
  1556.    Colores(WHITE,BLACK);
  1557.    gotoxy(45,11);
  1558.    printf("Editora");
  1559.    CapChar(&livre.editora,1,'!',42,13,15);
  1560.    gotoxy(45,13);
  1561.    printf("Fecha de publicacion");
  1562.    livre.fechaedicion.dd = 0;
  1563.    livre.fechaedicion.mm = 0;
  1564.    livre.fechaedicion.yyy = 0;
  1565.    Fechas(&livre.fechaedicion.dd,&livre.fechaedicion.mm,&livre.fechaedicion.yyy,30,13);
  1566.    return livre;
  1567. }
  1568.  
  1569. void ScrollingLIBRO(NODOL **cab, NODOL **cola, int *n, NODOA *cabA, NODOP *cabezaP)
  1570. {
  1571.     NODOL *IND,*CabezaActual;
  1572.     NODOP *INDP;
  1573.     CabezaActual = *cab;
  1574.     int indy = 6,indice = 1,busqueda=0;
  1575.     char letra,teclaBorrar;
  1576.     Colores(BLACK,WHITE);
  1577.    indy = 6;
  1578.    int select = 0,Turno = 0,res;
  1579.    char tecla;
  1580.    
  1581.    _setcursortype(0);
  1582.    do{
  1583.       impLibro(indy,CabezaActual,cola,YELLOW,BLACK,&select,*n);
  1584.       tecla = getch();
  1585.  
  1586.       if ( tecla == ARRIBA)
  1587.       {
  1588.          if(CabezaActual != *cab){
  1589.          select--;
  1590.          Turno--;
  1591.  
  1592.    }
  1593.          
  1594.       }
  1595.  
  1596.       if ( tecla == ABAJO )
  1597.       {
  1598.          select++;
  1599.          Turno++;
  1600.          if(Turno >= 4){
  1601.            CabezaActual = CabezaActual->sig;
  1602.            select = 3;
  1603.          }
  1604.          if ( Turno == (*n) )
  1605.             {  select = 0;
  1606.                CabezaActual = *cab;
  1607.                Turno = 0;
  1608.             }
  1609.       }
  1610.      
  1611.       if(tecla == BORRAR){
  1612.          for(IND = *cab;IND;IND = IND->sig){
  1613.             if(busqueda == Turno)
  1614.             {     for(INDP=cabezaP;INDP;INDP = INDP->sig){
  1615.                         res = Comparar(IND->libro.ISBN,INDP->prestamos.ISBN);
  1616.                         if(res == 1){
  1617.                            break;
  1618.                         }
  1619.                      }
  1620.                   break;
  1621.             }
  1622.            busqueda++;
  1623.          }
  1624.          if(res != 1){
  1625.             SeguroBorrar(&teclaBorrar);
  1626.             if(teclaBorrar == 's'){
  1627.                EliminarAutor(cab,cola,Turno);
  1628.                (*n)--;
  1629.                tecla = ESP;
  1630.             }
  1631.          }
  1632.          else if(res == 1){
  1633.             gotoxy(40,15);
  1634.             Colores(WHITE,LIGHTRED);
  1635.             printf("Libro esta prestado...");
  1636.             Sleep(1500);
  1637.             gotoxy(40,15); Colores(BLACK,BLACK);
  1638.             printf("                                      ");
  1639.            
  1640.          }
  1641.       }
  1642.         if(tecla == ENTER)
  1643.         {
  1644.             for (IND = *cab; IND; IND = IND->sig)
  1645.             {
  1646.                 if(busqueda == Turno)
  1647.                 {
  1648.                     EditorLIBRO(cab,cola,&IND,cabA);
  1649.                     break;
  1650.                 }
  1651.                 busqueda++;
  1652.             }
  1653.             tecla = ESP;
  1654.         }
  1655.    }while ( tecla != ESP && tecla != ENTER );
  1656.  
  1657.    if ( tecla == ESP )
  1658.       select = -1;
  1659.    
  1660. }
  1661.  
  1662. void impLibro(int y,NODOL *cabactual, NODOL **cola, int CFS, int CTS, int *sel, int Num)
  1663. {
  1664.     int indice = 0,info,mayor = 25,x,cont,MayorindN=6,MayorindA = 8,MayorindT = 8,posy,mayorNAT=10;
  1665.    NODOL *IND;
  1666.    // Evaluar impresion tabulada
  1667.  
  1668.           for (IND = cabactual; IND; IND = IND->sig){
  1669.              info = PalabraG(IND->libro.titulo);
  1670.              if(info > mayor)
  1671.              {
  1672.                  mayor = info;
  1673.              }
  1674.              if(info > mayorNAT)
  1675.              {
  1676.                 mayorNAT = info;
  1677.              }
  1678.              info = PalabraG(IND->libro.editora);
  1679.              if(info > mayor)
  1680.              {
  1681.                  mayor = info;
  1682.              }
  1683.              if(info > mayorNAT)
  1684.              {
  1685.                 mayorNAT = info;
  1686.              }
  1687.  
  1688.    
  1689. }
  1690.        for (IND = cabactual; IND; IND = IND->sig){
  1691.          info = PalabraG(IND->libro.titulo);
  1692.           if(info > MayorindN)
  1693.           {
  1694.               MayorindN = info;
  1695.           }
  1696.          info = PalabraG(IND->libro.editora);
  1697.           if(info > MayorindA)
  1698.           {
  1699.               MayorindA = info;
  1700.           }
  1701.  
  1702.     }
  1703.    if( cabactual != *cola){
  1704.    for (IND = cabactual; IND; IND = IND->sig,indice++){
  1705.          
  1706.       if(y <= 9){
  1707.  
  1708.          // imprimir tabla
  1709.          gotoxy(40,y);
  1710.          if(y == 6 || y == 8)
  1711.             Colores(BLUE,LIGHTCYAN);
  1712.          if(y == 7 || y == 9)
  1713.             Colores(LIGHTCYAN,BLUE);
  1714.          if ( indice == *sel )
  1715.            {Colores(CFS,CTS);}
  1716.          
  1717.          
  1718.       x = 40;
  1719.        for(cont=0; cont<mayor;cont++)
  1720.        {
  1721.             gotoxy(x,y);
  1722.             printf(" ");
  1723.            x++;
  1724.        }
  1725.          gotoxy(40,y);
  1726.          printf("%s",IND->libro.editora);
  1727.          // evalua nombres denuevo para saber la posision del apellido
  1728.          x = 41 + MayorindN;
  1729.          gotoxy(x,y);
  1730.          printf(" %s",IND->libro.titulo);
  1731.          gotoxy(x+MayorindA+1,y);
  1732.          printf(" %02d/%02d/%d",IND->libro.fechaedicion.dd,IND->libro.fechaedicion.mm,IND->libro.fechaedicion.yyy);
  1733.          }
  1734.       y++;
  1735.       }
  1736.    }
  1737.    else{
  1738.       for (IND = cabactual; IND; IND = IND->ant,indice++){
  1739.             if(y <= 9){
  1740.                   // imprimir tabla
  1741.          gotoxy(40,y);
  1742.          if(y == 6 || y == 8)
  1743.             Colores(BLUE,LIGHTCYAN);
  1744.          if(y == 7 || y == 9)
  1745.             Colores(LIGHTCYAN,BLUE);
  1746.          if ( indice == *sel )
  1747.            {Colores(CFS,CTS);}
  1748.          
  1749.          
  1750.       x = 40;
  1751.        for(cont=0; cont<mayor;cont++)
  1752.        {
  1753.             gotoxy(x,y);
  1754.             printf(" ");
  1755.            x++;
  1756.        }
  1757.          gotoxy(40,y);
  1758.          printf("%s",IND->libro.titulo);
  1759.          // evalua titulo denuevo para saber la posision del apellido
  1760.          x = 41 + MayorindN;
  1761.          gotoxy(x,y);
  1762.          printf(" %s",IND->libro.editora);
  1763.          gotoxy(x+MayorindA+1,y);
  1764.          printf("%02d/%02d/%d",IND->libro.fechaedicion.dd,IND->libro.fechaedicion.mm,IND->libro.fechaedicion.yyy);
  1765.          }
  1766.       y++;
  1767.       }
  1768.    }
  1769.       gotoxy(40,5);
  1770.     Colores(WHITE,BLACK);
  1771.     printf("EDITORA");
  1772.     cont = 6;
  1773.    if(MayorindN > 6)
  1774.       for(cont;cont<MayorindN;cont++){
  1775.          printf(" ");
  1776.       }
  1777.       printf("|");
  1778.  
  1779.       x = 41 + MayorindN;
  1780.       gotoxy(x,5);
  1781.       printf(" TITULO");
  1782.       cont = 8;
  1783.       for(cont;cont<MayorindA;cont++){
  1784.          printf(" ");
  1785.       }
  1786.       printf("|");
  1787.       if(MayorindN > 6 || MayorindA > 8){
  1788.          x = 42+mayorNAT+MayorindA;}
  1789.       else{
  1790.          x = 56;
  1791.       }
  1792.      /*for(posy=6;posy<Num+6;posy++){
  1793.          gotoxy(x,posy);
  1794.          printf("|");
  1795.       }*/
  1796.       if(MayorindA > 8 || MayorindN > 6){
  1797.          x = 56 + MayorindA;}
  1798.       else{
  1799.          x = 57;
  1800.       }
  1801.       gotoxy(x,5);
  1802.       printf(" FECHA ");
  1803.    
  1804.       return;
  1805. }
  1806.  
  1807. int EliminarLibro(NODOL **cabeza,NODOL **cola,int Dato)
  1808. {
  1809.     NODOL *actual = *cabeza,*anteriot,*siguiente;
  1810.     char *NomBuscar;
  1811.     NomBuscar = (char *)malloc(sizeof(char));
  1812.     int indice = 0;
  1813.  
  1814.    
  1815.     while(actual != NULL)
  1816.     {
  1817.         if(indice == Dato)
  1818.         {
  1819.             if( actual == *cabeza)
  1820.             {
  1821.                *cabeza = actual->sig;
  1822.                
  1823.             }
  1824.             else if( actual->sig == NULL)
  1825.             {
  1826.                 anteriot = actual->ant;
  1827.                 *cola = anteriot;
  1828.                 anteriot->sig = NULL;
  1829.             }
  1830.             else
  1831.             {
  1832.                 anteriot = actual->ant;
  1833.                 actual->ant = NULL;
  1834.                 siguiente = actual->sig;
  1835.                 actual->sig = NULL;
  1836.                 anteriot->sig = siguiente;
  1837.                 siguiente->ant = anteriot;
  1838.                
  1839.             }
  1840.             free(actual);
  1841.             return 1;
  1842.         }
  1843.         actual = actual->sig;
  1844.         indice++;
  1845.     }
  1846.     return 0;
  1847. }
  1848.  
  1849. void EditorLIBRO(NODOL **cabeza,NODOL **cola,NODOL **actual, NODOA *cabA){
  1850.             char idAutor[LENIDAUTOR],resp;
  1851.             int Busqueda;
  1852.             Limpiar();
  1853.             gotoxy(15,2);
  1854.             Colores(WHITE,RED);
  1855.             printf("Presione (ENTER) si no desea editar nada\n (Espacio en las fechas)");
  1856.             gotoxy(25,4);
  1857.                   Colores(WHITE,BLACK);
  1858.                   printf("Titulo: ");
  1859.                   gotoxy(70,3);
  1860.                   printf("Editorial: ");
  1861.                   gotoxy(60,9);
  1862.                   printf("ISBM");
  1863.                  
  1864.                   gotoxy(25,4);
  1865.                  
  1866.                   printf("Titulo: ");
  1867.                   CapChar((*actual)->libro.titulo,1,'A',40,7,16);
  1868.                  
  1869.                   gotoxy(70,3);
  1870.                   printf("Editorial: ");
  1871.                   CapChar((*actual)->libro.editora,1,'A',85,7,16);
  1872.                  
  1873.                   gotoxy(60,9);
  1874.                   printf("ISBM");
  1875.                   CapChar((*actual)->libro.ISBN,1,'3',70,12,16);
  1876.                   gotoxy(45,9);
  1877.    printf("ID del autor (si no tiene precione ENTER)");
  1878.    do{
  1879.       CapChar(idAutor,1,'5',42,11,16);
  1880.       Busqueda = BuscarAutor(cabA,idAutor);
  1881.       if(idAutor[0] == '\r'){
  1882.          Busqueda = 2;
  1883.       }
  1884.       if(Busqueda == 1){
  1885.          gotoxy(45,3);
  1886.          Colores(WHITE,LIGHTGREEN);
  1887.          printf("ID asignado de forma correcta");
  1888.          strcpy((*actual)->libro.idautor,idAutor);
  1889.          Sleep(1000); gotoxy(45,3); Colores(BLACK,BLACK);
  1890.          printf("                               ");
  1891.       }
  1892.       else if(Busqueda == 0){
  1893.          gotoxy(45,3);Colores(WHITE,LIGHTGREEN);
  1894.          printf("ID no existe, %cdesea ingresar otro? Si o No",168);
  1895.          do{
  1896.                resp = toupper(getch());
  1897.                if(resp == 'N'){
  1898.                   Busqueda = 2;
  1899.                }
  1900.          }while(resp != 'N' && resp != 'S');
  1901.          gotoxy(45,3);Colores(BLACK,BLACK);
  1902.          printf("                                                ");
  1903.          
  1904.       }
  1905.    }while(Busqueda == 0);
  1906.                  
  1907.  
  1908.       }
  1909. LIBRO existeLIBRO(NODOL *cab, char *Busq){
  1910.          NODOL *IND;
  1911.          int retorno;
  1912.    LIBRO Encontrado,Ninguno = {ENTER,ENTER,ENTER,ENTER,ENTER,ENTER};
  1913.    for(IND=cab;IND;IND=IND->sig){
  1914.       retorno = Comparar(IND->libro.editora,Busq);
  1915.       if(retorno == 1){
  1916.          Encontrado = IND->libro;
  1917.          return Encontrado;
  1918.       }
  1919.       retorno = Comparar(IND->libro.idautor,Busq);
  1920.       if(retorno == 1){
  1921.          Encontrado = IND->libro;
  1922.          return Encontrado;
  1923.       }
  1924.       retorno = Comparar(IND->libro.ISBN,Busq);
  1925.       if(retorno == 1){
  1926.          Encontrado = IND->libro;
  1927.          return Encontrado;
  1928.       }
  1929.       retorno = Comparar(IND->libro.titulo,Busq);
  1930.       if(retorno == 1){
  1931.          Encontrado = IND->libro;
  1932.          return Encontrado;
  1933.       }
  1934.    }
  1935.    return Ninguno;
  1936. }
  1937. /// Utiles                                                                                              
  1938.  
  1939. void Limpiar()
  1940. {
  1941.     Colores(BLACK,BLACK);
  1942.     system("CLS");
  1943. }
  1944.  
  1945.  
  1946.  
  1947.  
  1948. int PalabraG(char *aux){
  1949.    int ind = 0,PMayor = 0;
  1950.    while(aux[ind] != ENTER){
  1951.       PMayor++;
  1952.       ind++;
  1953.    }  
  1954.    
  1955.    return PMayor;
  1956.    
  1957. }
  1958.  
  1959. void SeguroBorrar(char *tecla){
  1960.    char resp;
  1961.          gotoxy(40,15);
  1962.          printf("%cSegur%c que desea eliminar?",168,64);
  1963.          *tecla = 'n';
  1964.          _setcursortype(1);
  1965.          gotoxy(50,16);
  1966.             printf("Si");
  1967.             gotoxy(55,16);
  1968.             printf("No");
  1969.          do{
  1970.            
  1971.             resp = getch();
  1972.             if(resp == DERECHA){
  1973.                gotoxy(55,16);
  1974.                *tecla = 'n';
  1975.             }
  1976.             if(resp == IZQUIERDA){
  1977.                gotoxy(50,16);
  1978.                *tecla = 's';
  1979.             }
  1980.            
  1981.          }while(resp != ENTER);
  1982. }
  1983.  
  1984. int BuscarAutor(NODOA *cab, char *busq){
  1985.    NODOA *IND;
  1986.    int res;
  1987.    for(IND=cab;IND;IND = IND->sig){
  1988.       res = Comparar(IND->autor.idautor,busq);
  1989.       if(res == 1){
  1990.          return 1;
  1991.       }
  1992.    }
  1993.    return 0;
  1994. }
  1995.  
  1996. PRESTAMOS SolicitarPrestamo(USUARIO *Infouser, LIBRO InfoLibro ){
  1997.    
  1998.    time_t t;
  1999.    struct tm *tm;
  2000.    t = time(NULL);
  2001.    tm = localtime(&t);
  2002.  
  2003.    PRESTAMOS NPrestamo;
  2004.    Limpiar();
  2005.    int NDias,ind;
  2006.    Colores(WHITE,BLACK);
  2007.    strcpy(NPrestamo.iddocumento,Infouser->nombres);
  2008.    strcpy(NPrestamo.ISBN,InfoLibro.ISBN);
  2009.    gotoxy(40,2);
  2010.    printf("Libro: %s",InfoLibro.titulo);
  2011.    gotoxy(40,5);
  2012.    printf("Fecha Del Prestamo: ");
  2013.    NPrestamo.fecprestamo.dd = tm->tm_mday;
  2014.    NPrestamo.fecprestamo.mm = tm->tm_mon+1;
  2015.    NPrestamo.fecprestamo.yyy = 1900+tm->tm_year;
  2016.    //Fechas(&NPrestamo.fecprestamo.dd,&NPrestamo.fecprestamo.mm,&NPrestamo.fecprestamo.yyy,62,5);
  2017.    gotoxy(62,5); Colores(LIGHTRED,WHITE);
  2018.    printf("%02d/%02d/%d",NPrestamo.fecprestamo.dd,NPrestamo.fecprestamo.mm,NPrestamo.fecprestamo.yyy);
  2019.    gotoxy(40,7); Colores(YELLOW,LIGHTRED);
  2020.    printf("Ingrese la cantidad de dias del prestamo\nRecargo diario: 100RD$");
  2021.    gotoxy(40,8);
  2022.    printf("(Mayor que 4 d%cas, Menor que 1 mes)",161);
  2023.    NDias = NumerosC(2,0,45,9);
  2024.    NPrestamo.diasprestamo = NDias;
  2025.    gotoxy(40,10);
  2026.    printf("Mantenga pendiente la fecha de devoluci%cn: ",162);
  2027.    NPrestamo.fecdevolucion.dd = NPrestamo.fecprestamo.dd;
  2028.    NPrestamo.fecdevolucion.mm = NPrestamo.fecprestamo.mm;
  2029.    NPrestamo.fecdevolucion.yyy = NPrestamo.fecprestamo.yyy;
  2030.    for(ind=0;ind<NDias;ind++){
  2031.       NPrestamo.fecdevolucion.dd++;
  2032.       if(NPrestamo.fecdevolucion.dd >= 31){
  2033.          NPrestamo.fecdevolucion.dd = 1;
  2034.          NPrestamo.fecdevolucion.mm++;
  2035.          if(NPrestamo.fecdevolucion.mm > 12 ){
  2036.             NPrestamo.fecdevolucion.mm = 1;
  2037.             NPrestamo.fecdevolucion.yyy++;
  2038.          }
  2039.       }
  2040.       else if(NPrestamo.fecdevolucion.dd > 29 && NPrestamo.fecdevolucion.mm == 2){
  2041.          NPrestamo.fecdevolucion.dd = 28;
  2042.       }
  2043.    }
  2044.    Colores(YELLOW,LIGHTRED);
  2045.    gotoxy(85,10);
  2046.    printf("%d/%d/%d",NPrestamo.fecdevolucion.dd,NPrestamo.fecdevolucion.mm,NPrestamo.fecdevolucion.yyy);
  2047.    NPrestamo.recargodiario = 100;
  2048.    printf("\nPrecio total: [%d]",NDias*100);
  2049.    _setcursortype(0);
  2050.    char l = getch();
  2051.    return NPrestamo;
  2052. }
  2053.  
  2054. int Comparar(char *str1, char *str2){
  2055.    int ind=0,TamL1=0,TamL2=0,cmp=0;
  2056.    
  2057.    while(str1[ind] != '\r'){
  2058.       TamL1++;ind++;
  2059.       if(str1[ind] == '\0'){
  2060.          break;
  2061.       }
  2062.    }
  2063.    ind = 0;
  2064.    while(str2[ind] != '\r'){
  2065.       TamL2++;ind++;
  2066.       if(str2[ind] == '\0'){
  2067.          break;
  2068.       }
  2069.    }
  2070.    if(TamL1 == TamL2){
  2071.       for(ind=0;ind<TamL1;ind++){
  2072.          if(toupper(str1[ind]) == toupper(str2[ind])){
  2073.             cmp++;
  2074.          }
  2075.       }
  2076.       if(cmp == TamL1){
  2077.          return 1;
  2078.       }
  2079.    }
  2080.    return 0;
  2081. }
  2082.  
  2083. int ValidaFechas(int D1, int M1, int Y1, int D2, int M2, int Y2){
  2084.    if(Y2 > Y1){
  2085.       return 2;
  2086.    }
  2087.    else if( Y1 > Y2){
  2088.       return 1;
  2089.    }
  2090.    else{
  2091.       if( M1 > M2 ){
  2092.          return 1;
  2093.       }
  2094.       if(M2 > M1){
  2095.          return 2;
  2096.       }
  2097.       if(D1 > D2){
  2098.          return 1;
  2099.       }
  2100.       if(D2 > D1){
  2101.          return 2;
  2102.       }
  2103.    }
  2104.    return 0;
  2105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement