Guest User

Untitled

a guest
Sep 2nd, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 8.74 KB | None | 0 0
  1.        identification division.
  2.        program-id. menuadh.
  3.  
  4.        file-control.
  5.        select f-adh assign "data\adherent.dat" organization indexed
  6.            access mode is dynamic
  7.            record key CodeE.
  8.  
  9.        select f-pret assign "data\pret.dat" organization indexed
  10.            access mode is dynamic
  11.            record key is clef = DatePret, RefS, CodeA
  12.            alternate key RefS duplicates
  13.            alternate key CodeA duplicates.
  14.  
  15.        select f-hist assign "f-hist.dat" organization record sequential.
  16.  
  17.        data division.
  18.  
  19.        file section.
  20.            fd f-adh.
  21.                1 adherent.
  22.                    2 CodeE pic x(5).
  23.                    2 NomE pic x(30).
  24.                    2 PrenomE pic x(30).
  25.                    2 AdrE pic x(150).
  26.            fd f-pret.
  27.                1 pret.
  28.                    2 DatePret pic 9(8).
  29.                    2 RefS pic x(5).
  30.                    2 CodeA pic x(5).
  31.                    2 DateRetour pic 9(8).
  32.  
  33.            fd f-hist.
  34.                1 hist.
  35.                    2 DateOp pic 9(8).
  36.                    2 Login pic x(10).
  37.                    2 CodeOp pic x(1).
  38.                    2 NomFich pic x(20).
  39.                    2 ClePrim pic x(10).
  40.                    2 CodeEt pic x(1).
  41.  
  42.        working-storage section.
  43.  
  44.        01 choix pic 99.
  45.        01 v-fin-f-adh pic x value 'N'.
  46.        88 fin-f-adh value 'O' false 'N'.
  47.        01 a pic x(5).
  48.        01 bool pic 9.
  49.        01 datecour pic 9(8).
  50.        01 amende pic 999.
  51.        01 nbretard pic 99.
  52.  
  53.  
  54.        linkage section.
  55.            01 type-util pic 99.
  56.            01 slogin pic x(10).
  57.  
  58.        screen section.
  59.        01 a-plg-titre.
  60.            02 blank screen.
  61.            02 line 1 col 25 value '###############################'.
  62.            02 line 2 col 25 value '#                             #'.
  63.            02 line 3 col 25 value '#   GESTION DES ADHERENTS     #'.
  64.            02 line 4 col 25 value '#                             #'.
  65.            02 line 5 col 25 value '###############################'.
  66.  
  67.        01 a-plg-menu2.
  68.            02 line 8 col 2 value '#1 : Consulter une fiche'.
  69.            02 line 10 col 2 value '#2 : Ajouter une fiche'.
  70.            02 line 12 col 2 value '#3 : Modifier une fiche'.
  71.            02 line 14 col 2 value '#4 : Calculer une amende'.
  72.            02 line 16 col 2 value '#0 : Retour au menu'.
  73.  
  74.        01 a-plg-menuadmin.
  75.            02 line 8 col 2 value '#1 : Consulter une fiche'.
  76.            02 line 10 col 2 value '#2 : Ajouter une fiche'.
  77.            02 line 12 col 2 value '#3 : Modifier une fiche'.
  78.            02 line 14 col 2 value '#4 : Calculer une amende'.
  79.            02 line 16 col 2 value '#5 : Supprimer une fiche'.
  80.            02 line 18 col 2 value '#0 : Retour au menu'.
  81.  
  82.        01 s-plg-menuchoix.
  83.            02 line 23 col 30 value 'Entrez la valeur de votre choix..'.
  84.            02 s-choix pic zz to choix required auto.
  85.  
  86.        01 a-bug.
  87.            02 line 20 col 20 value 'Mauvaise entree'.
  88.  
  89.        procedure division using type-util, slogin.
  90.  
  91.            open i-o f-adh
  92.            open i-o f-pret
  93.            open extend f-hist
  94.            display a-plg-titre
  95.            evaluate type-util
  96.                when 0 display a-plg-menuadmin
  97.                when 2 display a-plg-menu2
  98.                when other display a-bug
  99.            end-evaluate
  100.            display s-plg-menuchoix
  101.            accept choix
  102.            perform until(choix = 0)
  103.                evaluate choix
  104.                    when 1 perform consult-adh
  105.                           compute choix = 0
  106.                    when 2 perform ajout-adh
  107.                           compute choix = 0
  108.                    when 3 perform modif-adh
  109.                           compute choix = 0
  110.                    when 4 perform calcul-amende
  111.                           compute choix = 0
  112.                    when 5 perform supp-adh
  113.                           compute choix = 0
  114.                    when 0 continue
  115.                    when other display a-bug
  116.                end-evaluate
  117.            end-perform
  118.            close f-adh
  119.            close f-pret
  120.            close f-hist
  121.  
  122.        goback.
  123.  
  124.        ajout-adh.
  125.            display 'Code de l''adherent?'
  126.            accept CodeE of adherent
  127.            display 'Nom de l''adherent ?'
  128.            accept NomE of adherent
  129.            display 'Prenom de l''adherent ?'
  130.            accept PrenomE of adherent
  131.            display 'Adresse de l''adherent ?'
  132.            accept AdrE of adherent
  133.            write adherent
  134.            move 'A' to CodeOp
  135.            move 'adherent.dat' to NomFich
  136.            move 'R' to CodeEt
  137.            move CodeE to ClePrim
  138.            move slogin to Login
  139.            write hist
  140.            display 'Adherant ajoute'.
  141.        .
  142.  
  143.        consult-adh.
  144.            display 'Code de l''adherent ?'
  145.            accept CodeE of adherent
  146.            start f-adh key = CodeE
  147.                invalid key
  148.                    display 'Adherent inconnu'
  149.                    display 'Tapez Entree pour continuer'
  150.                    accept choix
  151.                not invalid
  152.                    read f-adh
  153.                    display NomE of adherent
  154.                    display PrenomE of adherent
  155.                    display AdrE of adherent
  156.                    display 'Tapez Entree pour continuer'
  157.                    accept choix
  158.            end-start
  159.        .
  160.  
  161.        modif-adh.
  162.            display 'Code de l''adherent ?'
  163.            accept CodeE of adherent
  164.            start f-adh key = CodeE
  165.                invalid key
  166.                    display 'Adherent inconnu'
  167.                    display 'Tapez Entree pour continuer'
  168.                    move 'E' to CodeEt
  169.                    accept choix
  170.                not invalid
  171.                    display 'Nouveau nom de l''adherent?'
  172.                    accept NomE of adherent
  173.                    display 'Nouveau prenom de l''adherent?'
  174.                    accept PrenomE of adherent
  175.                    display 'Nouvelle adresse de l''adherent?'
  176.                    accept AdrE of adherent
  177.                    display 'Tapez Entree pour continuer'
  178.                    accept choix
  179.                    rewrite adherent
  180.                    move 'R' to CodeEt
  181.  
  182.            end-start
  183.  
  184.  
  185.            move 'adherent.dat' to NomFich
  186.            move CodeE to ClePrim
  187.            move slogin to Login
  188.            write hist
  189.  
  190.        .
  191.  
  192.        supp-adh.
  193.            display 'Code de l''adherent ?'
  194.            accept CodeE of adherent
  195.            start f-adh key = CodeE
  196.                invalid key
  197.                    display 'Adherent inconnu'
  198.                    move 'E' to CodeEt
  199.  
  200.                not invalid
  201.                    display 'Voulez-vous vraiment supprimer l''adherent?'
  202.                    display '(0 : non, 1 : oui)'
  203.                    accept choix
  204.                    evaluate choix
  205.                        when 0 display 'Adherent non supprime'
  206.                        move 'E' to CodeEt
  207.  
  208.                        when 1 delete f-adh
  209.                               display 'Adherent supprime'
  210.                        move 'R' to CodeEt
  211.  
  212.                        when other display 'Adherent non supprime'
  213.                    end-evaluate
  214.                    display 'Appuyez sur Entree pour continuer'
  215.                    accept choix
  216.  
  217.            end-start
  218.  
  219.  
  220.            move 'adherent.dat' to NomFich
  221.            move CodeE to ClePrim
  222.            move slogin to Login
  223.            write hist
  224.        .
  225.  
  226.        calcul-amende.
  227.            move function current-date(1:8) to datecour
  228.            move 0 to amende
  229.            move 0 to nbretard
  230.            move 0 to bool
  231.            display 'Code adherent ?'
  232.            accept CodeA of pret
  233.            move CodeA to a
  234.            start f-pret key = CodeA
  235.                invalid key
  236.                    display 'Adherent inconnu'
  237.                not invalid
  238.                    read f-pret next
  239.                        end move 1 to bool
  240.                    end-read
  241.                    perform until(bool = 1)
  242.                        if(DateRetour = '00000000' AND CodeA = a) then
  243.                 compute nbretard = function integer-of-date(datecour) -
  244.                            function integer-of-date(DatePret)
  245.                            if(nbretard > 21) then
  246.                  compute nbretard = nbretard - 21
  247.                  compute amende = amende + (nbretard * 0.5)
  248.                            end-if
  249.                         end-if
  250.                         read f-pret next
  251.                            end move 1 to bool
  252.                         end-read
  253.                     end-perform
  254.            end-start
  255.            display 'Valeur de l''amende :'
  256.            display amende
  257.            display 'Tapez Entree pour continuer'
  258.            accept choix
  259.        .
  260.  
  261.        End program menuadh.
Add Comment
Please, Sign In to add comment