Пример #1
0
/** \brief Set this employee the values recived as parameters
 *
 * \param pEmployee employee*
 * \param id int
 * \param name[] char
 * \param lastName[] char
 * \param salary float
 * \param sector int
 * \return int Return (-1) if Error [NULL pointer] - (0) if Ok
 *
 */
Employee* newEmployee(void)
{
    Employee* returnAux = NULL;
    Employee* pEmployee = malloc(sizeof(Employee));
    if(pEmployee != NULL)
    {
        int legajo=getValidInt("\nIngrese legajo:","\nError, reingrese...",1,10000);
        pEmployee->id=legajo;

        char apellido[51];
        getValidString("\nIngrese apellido del empleado:","\nError, reingrese...",apellido);
        strcpy(pEmployee->lastName,apellido);

        char nombre[51];
        getValidString("\nIngrese nombre del empleado:","\nError, reingrese...",nombre);
        strcpy(pEmployee->name,nombre);

        pEmployee->salary=getFloat("\nIngrese sueldo:");

        pEmployee->isEmpty = 0;

        returnAux = pEmployee;
    }
    return returnAux;
}
void adminBooks(book bookArray[])
{
    // variables auxiliares
    char titleAux[51];

    int authorIdAux;
    int codeAux;
    int stockAux;
    //________________________________________________

    int freePlaceIndex;
    int foundIndex;
    int option = 0;

    while(option != 6)
    {
         system("@cls||clear");
         printf("\n------------  ABM LIBROS ------------");
         option = getInt("\n1 - ALTA \n2 - BAJA \n3 - MODIFICACION\n4 - LISTAR\n5 - ORDENAR\n6 - REGRESAR\n\n\n");
         switch(option)
         {
            case 1: // ALTA DE LIBRO

                freePlaceIndex = findBookEmptyPlace(bookArray,MAX_QTY);
                if(freePlaceIndex == -1)
                {
                    printf("\n\nNO QUEDAN LUGARES LIBRES!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                codeAux = getValidInt("Ingrese el codigo del libro: ","El codigo del libro debe ser numerico\n", 1, 15000);
                if(findBookByCode(bookArray,MAX_QTY,codeAux) != -1)
                {
                    printf("\n\nEL CODIGO YA EXISTE!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                authorIdAux =  getValidInt("Ingrese el ID del autor del libro: ","El ID del autor debe ser numerico\n", 1, 500);

                stockAux = getValidInt("Ingrese la cantidad de libros: ","La cantidad debe ser numerica\n", 1, 10000);

                getValidString("Ingrese el titulo: ","El titlo debe estar compuesto solo por letras\n", titleAux);

                setBook(bookArray,freePlaceIndex,codeAux,titleAux,authorIdAux,stockAux);

                break;

            case 2: // BAJA LIBRO

                codeAux = getValidInt("Ingrese el codigo de libro a dar de baja: ","El codigo del libro debe ser numerico\n", 1, 15000);
                foundIndex = findBookByCode(bookArray,MAX_QTY,codeAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }
                bookArray[foundIndex].status = 0;
                break;

            case 3: // MODIFICAR LIBRO

                codeAux = getValidInt("Ingrese el codigo del libro a modificar: ","El codigo del libro debe ser numerico\n", 1, 15000);
                foundIndex = findBookByCode(bookArray,MAX_QTY,codeAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }


                authorIdAux =  getValidInt("Ingrese el ID del autor del libro: ","El ID del autor debe ser numerico\n", 1, 500);

                stockAux = getValidInt("Ingrese la cantidad de libros: ","La cantidad debe ser numerica\n", 1, 10000);

                getValidString("Ingrese el titulo: ","El titulo debe estar compuesto solo por letras\n", titleAux);

                setBook(bookArray,foundIndex,codeAux,titleAux,authorIdAux,stockAux);

                break;

            case 4: // LISTAR
                system("@cls||clear");
                showBookArray(bookArray,MAX_QTY);
                getChar("\n\nENTER (para continuar)");
                break;

            case 5: // ORDENAR
                orderBookArrayByTitle(bookArray,MAX_QTY);
                getChar("\n\nOrdenados. ENTER (para continuar)");
                break;


         }
    }
}
void adminAuthors(author authorArray[])
{
    // variables auxiliares
    char nameAux[51];
    char lastNameAux[51];
    int authorIdAux;
    //________________________________________________

    int freePlaceIndex;
    int foundIndex;
    int option = 0;

    while(option != 4)
    {
         system("@cls||clear");
         printf("\n------------  ABM AUTORES ------------");
         option = getInt("\n1 - ALTA \n2 - BAJA \n3 - LISTAR\n4 - REGRESAR\n\n\n");
         switch(option)
         {
            case 1: // ALTA DE autor

                freePlaceIndex = findAuthorEmptyPlace(authorArray,MAX_QTY);
                if(freePlaceIndex == -1)
                {
                    printf("\n\nNO QUEDAN LUGARES LIBRES!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                authorIdAux = getValidInt("Ingrese el codigo del autor: ","El codigo del autor debe ser numerico\n", 1, 500);
                if(findAuthorById(authorArray,MAX_QTY,authorIdAux) != -1)
                {
                    printf("\n\nEL CODIGO YA EXISTE!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                getValidString("Ingrese el nombre del autor: ","El nombre debe estar compuesto solo por letras\n", nameAux);

                getValidString("Ingrese el apellido del autor: ","El nombre debe estar compuesto solo por letras\n", lastNameAux);

                setAuthor(authorArray,freePlaceIndex,authorIdAux,nameAux,lastNameAux);

                break;

            case 2: // BAJA AUTOR

                authorIdAux = getValidInt("Ingrese el codigo del autor: ","El codigo del autor debe ser numerico\n", 1, 500);
                foundIndex = findAuthorById(authorArray,MAX_QTY,authorIdAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }
                authorArray[foundIndex].status = 0;
                break;

            case 3: // LISTAR
                system("@cls||clear");
                showAuthorArray(authorArray,MAX_QTY);
                getChar("\n\nENTER (para continuar)");
                break;


         }
    }
}
Пример #4
0
void modify(eMovie *movie,int length)
{
    int codeAux;
    int option,ratingAux,durationAux;
    char titleAux[30],genreAux[50],linkAux [30],descriptionAux[30];

    if(campolleno(movie,QTY)==1)//0 nada cargado, -1 null y 1 cargaprevia
    {
        codeAux = getInt("Ingrese codigo de la pelicula a modificar\n");

        int i;
        for(i=0; i<length; i++)
        {
            if(movie[i].code==codeAux)
            {

                while(option!=7)
                {
                    option= getInt("\n 1- Titulo \n 2- Genero \n 3- Duracion \n 4- Descripcion\n 5- Puntaje\n 6- Link de imagen\n 7- Salir\n\n Ingrese una opcion: \n");
                    switch(option)
                    {
                    case 1: //titulo


                        getValidString("Ingrese titulo de la pelicula: \n","El titulo tiene que ser alfabetico",titleAux);
                        //fflush(stdin);
                        strcpy(movie[i].title,titleAux);
                        printf("Se cargo nuevo titulo %s\n", movie[i].title);
                        break;

                    case 2: //genero

                        //printf("%s\n", movie[i].genre);
                        getValidString("Ingrese genero de la pelicula: \n","El genero tiene que ser alfabetico",genreAux);
                        strcpy(movie[i].genre,genreAux);

                        break;

                    case 3://duracion

                       // printf("%d\n", movie[i].duration);
                        durationAux=getValidInt("Ingrese duracion total en minutos :\n","Ingrese datos numericos",30, 500);
                        movie[i].duration = durationAux;


                        break;

                    case 4:// descripcion


                        printf("la descripcion de la pelicula es: %s,\n", movie[i].description);
                        getString("Ingrese nueva descripcion: \n",descriptionAux);
                        strcpy(movie[i].description,descriptionAux);
                        break;


                    case 5://puntaje


                      //  printf("%d\n", movie[i].rating);
                        ratingAux = getValidInt("Ingrese nueva puntuacion :\n","Ingrese datos numericos",1, 100);
                        movie[i].rating= ratingAux;

                        break;
                    case 6://link

                        printf("El link de la pelicula es: %s,\n", movie[i].link);
                        getString("Ingrese nuevo link: \n",linkAux);
                        strcpy(movie[i].link, linkAux);
                        break;

                    case 7:
                        break;
                    default:
                        printf("Ingrese opcion de menu valida\n");

                    }//endSwitch

                }//cierre while

            } //cierre del if


        }

    }else
        {
          printf("No hay datos cargados para poder modificar\n");
        }
}
Пример #5
0
int addMovie(eMovie *movie,int length)
{
    int retorno = -1;
    int codeAux;
    char titleAux[50];
    char descriptionAux[1000];
    char genreAux[30];
    int ratingAux;
    int durationAux;
    char linkAux[300];
    int freeIndex;

    if(movie!=NULL && length>0)
    {

        freeIndex = searchFreePlace(movie,QTY);//si status==0 retorna el indice, sino 1.
        //printf("%d",freeIndex);
        if(freeIndex==-1)
        {
            printf("No hay mas espacio\n");
            //break; //cdo estaba en el case del main
        }

        codeAux=getValidInt("Ingrese codigo de pelicula: \n","Ingrese codigo numerico\n",1,1000);
        if(searchInt(movie,QTY,codeAux)!=-1)
        {
            printf("El codigo ya existe\n");
            // break;
        }
        else
        {
        getValidString("Ingrese titulo de la pelicula: \n","El titulo tiene que ser alfabetico",titleAux);

        fflush(stdin);

        getValidString("Ingrese descripcion de la pelicula: \n","La descripcion tiene que ser alfabetica",descriptionAux);
        fflush(stdin);
        getValidString("Ingrese genero de la pelicula: \n","El genero tiene que ser alfabetico",genreAux);
        fflush(stdin);
        durationAux=getValidInt("Ingrese duracion total en minutos :\n","Ingrese datos numericos",30, 500);
        fflush(stdin);
        ratingAux = getValidInt("Ingrese puntuacion :\n","Ingrese datos numericos",1, 100);
        fflush(stdin);
        //printf("LINK : %s",linkAux);
        system("pause");
        getStringL("Ingrese link de la pelicula: \n",linkAux);
        printf("link : %s\n",linkAux);
        fflush(stdin);
        setMovie(movie,freeIndex,codeAux,titleAux,descriptionAux,genreAux,durationAux,ratingAux,linkAux);
        printf("\nTitulo %s\nDuracion %d\n%s\n%s\n %d\n", movie[freeIndex].title,movie[freeIndex].duration,movie[freeIndex].description,movie[freeIndex].genre,movie[freeIndex].status);
        retorno=0;

        }



    }
    return retorno;


}