示例#1
0
int main()
{
    ArrayList* arrayListC=al_newArrayList();
    ArrayList* DeleteHistory=al_newArrayList();
    ArrayList* Backup=al_newArrayList();
    eEmployee* employeeAux;
    int id=0;
    int auxInt;
    int option;
    char continueDo='s';
//    loadCant(arrayListC);
    loadFile(arrayListC,"Nomina.dat");
    loadFile(DeleteHistory,"Exempl.dat");

//   loader(arrayListC);
    do
    {
        getInt(&option,"######CASO DE USO ARRAYLIST###\n\n1-Agregar un empleado\n2-Modificar empleado\n3-Eliminar empleado"
               "\n4-Tamaño de la nomina\n5-Informes\n6-Salir"
               "\n10-Salir\noption:","Opcion no valida\n",1,8);
        switch(option)
        {
        case 1:
            employeeAux=loadEmployee(arrayListC);
            auxInt=findByName(DeleteHistory,employeeAux->name,employeeAux->lastName);
            if(auxInt==-1)
            {
                id++;
                if(al_add(arrayListC,(void*)employeeAux))
                {
                    id--;
                }
            }
            else
            {
                getInt(&option,"\nEl empleado ya pertenecia a la empresa, desea agregarlo nuevamente?? \n1-Si\n2-No","Error opcion no valida",1,2);
                switch(option)
                {
                case 1:
                    employeeAux=(ArrayList*)arrayListC->get(DeleteHistory,auxInt);
                    al_push(arrayListC,(employeeAux->id-1),(void*)employeeAux);
                    al_remove(DeleteHistory,auxInt);
                    break;
                case 2:
                    id++;
                    if(al_add(arrayListC,(void*)employeeAux))
                    {
                        id--;
                    }
                }
                break;
            }
            break;
        case 2:
            modifyEmployee(arrayListC);
            break;
        case 3:
            deleteEmployee(arrayListC,DeleteHistory);
            break;
        case 4:
            printf("\n\n@@@@@@@@ HISTORIAL @@@@@@@\n\n");
            PrintEmployees(DeleteHistory);
            break;
        case 5:
            informes(arrayListC);
            break;
        case 6:
            continueDo='n';
            saveToFileActive(arrayListC,"Nomina.dat");
            saveToFileActive(DeleteHistory,"Exempl.dat");
            break;
        case 7:

            break;
        case 8:
            al_push(arrayListC,2,loadEmployee(arrayListC));

            break;

        default:
            break;
        }


    }
    while(continueDo!='n');
//    saveCant(arrayListC);


    return 0;
}
示例#2
0
int main()
{
    Employee employees[LEN_EMPLOYEES];
    initEmployees(employees,LEN_EMPLOYEES);
    char seguir = 'S';
    int id;
    char name[51];
    char lastName[51];
    float salary;
    int sector;

    do
    {
        system("cls");//system("clear");

        switch(menu())
        {
            case 1:

                system("cls");//system("clear");
                printf("---------ALTA--------\n\n");
                id = getId();
                strncpy(name,getStringSoloLetras("Ingrese NOMBRE: "),51);
                strncpy(lastName,getStringSoloLetras("Ingrese APELLIDO: "),51);
                salary = getFloat("Ingrese SALARIO: ");
                sector = getInt("Ingrese SECTOR: ");
                system("cls");//system("clear");
                if(addEmployee(employees,LEN_EMPLOYEES,id,name,lastName,salary,sector) == -1)
                {
                    printf("Error al ingresar datos!");
                }

                system("pause");

            break;

            case 2:
                system("cls");//system("clear");
                if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0)
                {
                    printf("NO HAY EMPLEADOS INGRESADOS!\n");
                }
                else
                {
                    printf("------------MODIFICAR-----------\n\n");
                    printEmployees(employees,LEN_EMPLOYEES);
                    id = getInt("\n\nIngrese ID del empleado que desea modificar: ");
                    if(findEmployeeById(employees,LEN_EMPLOYEES,id) == -1)
                    {
                        printf("NO EXISTE ESTE EMPLEADO\n");
                        system("pause");
                        break;
                    }

                    if(modifyEmployee(employees,LEN_EMPLOYEES,id) == -1)
                    {
                        printf("\nError!");
                    }

                }

                system("pause");
                system("cls");//system("clear");
                break;

            case 3:
                system("cls");//system("clear");
                if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0)
                {
                    printf("NO HAY EMPLEADOS INGRESADOS!\n");
                }
                else
                {
                    printf("------------ELIMINAR-----------\n\n");
                    printEmployees(employees,LEN_EMPLOYEES);
                    id = getInt("\n\nIngrese ID del empleado que desea eliminar: ");
                    if(findEmployeeById(employees,LEN_EMPLOYEES,id) == -1)
                    {
                        printf("NO EXISTE ESTE EMPLEADO\n");
                        system("pause");
                        break;
                    }

                    if(removeEmployee(employees,LEN_EMPLOYEES,id) == -1)
                    {
                        printf("\nError!");
                    }
                }

                system("pause");
                system("cls");//system("clear");
                break;

            case 4:
                system("cls");//system("clear");

                if(verifyAllEmpty(employees,LEN_EMPLOYEES) == 0)
                {
                    printf("NO HAY EMPLEADOS INGRESADOS!\n");
                }
                else
                {
                    printf("------------INFORMAR-----------\n\n");
                    sortEmployees(employees,LEN_EMPLOYEES);
                    printEmployees(employees,LEN_EMPLOYEES);
                }
                system("pause");
                system("cls");
                break;
        }

    }while(seguir == 'S');

    return 0;
}