banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

GEODATA DAYS 2024

#1 Mon 07 June 2010 16:10

lina145
Juste Inscrit !
Date d'inscription: 7 Jun 2010
Messages: 5

[MapBasic 6.5] plusieurs sélection dans une liste

Bonjours,

J'ai le problème suivant:

J'ai créé une bout de programme qui me permet, par rapport à une table de département présent dans une première listbox, d'en choisir et de les mettre dans une deuxième listbox. Je valide ma sélection et les communes concernées devrait apparaitre dans une troisième listbox. Le problème est que cette troisième listbox ne montre que les communes comprises dans le dernier dépratement sélectionnés.

Voila le bout de code qui me pause problème:

Code:

dim i as integer
dim y as integer
dim nom_dep as string

    if nb_dep_choisit <> 0 then

        for i = 1 to nb_dep_choisit
            nom_dep = tab_dep_choisit(i)
            for y = 1 to nb_dep_choisit
                select * from INSSEE where C = nom_dep into com_selectionne        
            next
        next

        REDIM tab_com (Tableinfo (com_selectionne, TAB_INFO_NROWS))        
        nb_com = Tableinfo (com_selectionne, TAB_INFO_NROWS)                    
        fetch first from com_selectionne                                            
        for i = 1 to nb_com        
            tab_com(i) = com_selectionne.col(1)                                    
            fetch next from com_selectionne
        Next

    end if

    browse * from com_selectionne
    alter control 11 title from variable tab_com

Quelqu'un aurait-il une idée pour ce qui me fait défaut?

Hors ligne

 

#2 Mon 07 June 2010 16:22

Spacejo
Membre
Lieu: Nancy
Date d'inscription: 17 Aug 2008
Messages: 2511

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Salut et bienvenue,

dim nom_dep as string
Donc ---> select * from INSSEE where C like "nom_dep" into com_selectionne
A+
Joël

Dernière modification par Spacejo (Mon 07 June 2010 16:23)

Hors ligne

 

#3 Mon 07 June 2010 16:27

lina145
Juste Inscrit !
Date d'inscription: 7 Jun 2010
Messages: 5

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Merci Joël pour votre réponse rapide. J'ai effectué les changements mas je n'ai toujours que les communes du dernier départements sélectionnés qui apparaissent dans ma dernière listbox.

Dernière modification par lina145 (Mon 07 June 2010 16:27)

Hors ligne

 

#4 Mon 07 June 2010 16:33

Spacejo
Membre
Lieu: Nancy
Date d'inscription: 17 Aug 2008
Messages: 2511

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Si tu as toujours les communes du département précédent c'est qu'il manque un redim du "nb_dep", non?

Dernière modification par Spacejo (Mon 07 June 2010 16:49)

Hors ligne

 

#5 Mon 07 June 2010 16:53

lina145
Juste Inscrit !
Date d'inscription: 7 Jun 2010
Messages: 5

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Non je n'ai pas les communes du départements précédents mais celle du dernier sélectionné. Par exemple si je sélectionne "Allier" puis "Cantal" seulement les communes du Cantal s'afficheront.

et on ne peut pas faire un redim que sur les tableaux?

Hors ligne

 

#6 Mon 07 June 2010 16:59

Spacejo
Membre
Lieu: Nancy
Date d'inscription: 17 Aug 2008
Messages: 2511

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Mais il n'y a pas la totalité du code là ?
Il manque des déclarations de variables.

Dernière modification par Spacejo (Mon 07 June 2010 17:01)

Hors ligne

 

#7 Mon 07 June 2010 17:02

lina145
Juste Inscrit !
Date d'inscription: 7 Jun 2010
Messages: 5

Re: [MapBasic 6.5] plusieurs sélection dans une liste

non le code et beaucoup plus long avec toutes les boites de dialogues. Depuis le début ça donne cela:

Code:

include "MAPBASIC.DEF"

'Déclaration des procédures

declare sub main
declare sub w_couche_ouverte
declare sub carte_ouverte(byval w_nom as string)
declare sub boite_cadastre
declare sub valider_cadastre
declare sub annuler_cadastre
declare sub valider
declare sub lst_choix_dep
declare sub ajout_dep
declare sub del_dep
declare sub selection_com
declare sub lst_choix_commune
declare sub ajout_commune
declare sub del_commune
declare sub recherche_com
declare sub boite_proprietaire
declare sub valider_proprietaire
declare sub annuler_proprietaire
declare sub debut_saisie
declare sub boite_saisie
declare sub valider_saisie
declare sub fin_saisie
declare sub boite_export
declare sub chemin_sauvegarde
declare sub valider_export
declare sub boite_recherche_proprio
declare sub lst_nom_proprio
declare function table_ouverte(byval w_table as string) as logical

'déclaration des tableaux

global tab_dep () as string
global tab_dep_choisit () as string
global tab_com () as string
global tab_com_choisit () as string
global tab_proprio () as string

Global path_projet as String

'déclaration pour stocker le nombre d'enregistrement dans les listes

global nb_dep as integer
global nb_dep_choisit as integer
global nb_com as integer
global nb_com_choisit as integer
global nb_proprio as integer

'déclaration de l'id de la fenêtre MapInfo

global id_map_win as integer

global nom_proprio as string
global section as string
global parcelle as integer
global com as string
global surface as integer
global repertoire as string
'_____________________________________________________________________________________________________________________
sub main

'Constitution du menu

    create ButtonPad "Cadastre" as 
        pushbutton 
            icon 180
            helpmsg "Nouvelle table cadastrale"
            calling w_couche_ouverte
        pushbutton
            icon 321
            helpmsg "Export du propriétaire" 
            calling boite_export
        pushbutton
            icon 175
            helpmsg "Recherche d'un propriétaire"
            calling boite_recherche_proprio
        pushbutton
            icon 55
            helpmsg "Début de la saisie"
            calling debut_saisie
        pushbutton
            icon 63
            helpmsg "Fin de la saisie"
            calling fin_saisie
        show        

    nb_dep = 0

end sub
_____________________________________________________________________________________________________________________
sub w_couche_ouverte

'Vérification de couche ouverte ou non puis appelle de la boite de dialogue

dim w_file as string
dim w_nom_table as string
dim couche as string
dim i as integer
    
    if table_ouverte("Cadastre") = FALSE then
        open table "X:\CADASTRE NUMERISE\1 - CORREZE\Cadastre clients cabinet\Cadastre.TAB" 
        call carte_ouverte("Cadastre")    
    end if

    if table_ouverte("departement") = FALSE then
        open table "C:\Documents and Settings\Ludovic\Bureau\celine\MAPBASIC\CADASTRE\TABLE\departement.TAB" 
        call carte_ouverte("departement")    
    end if

    if table_ouverte("INSSEE") = FALSE then
        open table "C:\Documents and Settings\Ludovic\Bureau\celine\MAPBASIC\CADASTRE\TABLE\INSSEE.TAB" 
        'couche = fileopendlg (path_projet & "\table","INSEE.TAB","tab","Ouverture de la couche INSEE")
        call carte_ouverte("INSSEE")    
    end if

    Set Map Zoom Entire
    call boite_cadastre

end sub
___________________________________________________________________________________________________________________
sub carte_ouverte(byval w_nom as string)

dim i as integer
dim w_couche_trouvee as logical

    w_couche_trouvee = FALSE

    id_map_win = 0
    for i = 1 to numwindows()
        if (windowInfo(i, WIN_INFO_TYPE) = WIN_MAPPER) then
            id_map_win = windowInfo(i, WIN_INFO_WINDOWID)
            print id_map_win
        end if
    next

    if (tableinfo(w_nom, TAB_INFO_MAPPABLE) = TRUE) then
        if (id_map_win = 0) then
            map from w_nom
            id_map_win = frontwindow()
        else
            for i = 1 to mapperinfo(id_map_win, MAPPER_INFO_LAYERS)
                if layerinfo(id_map_win, i, LAYER_INFO_NAME) = w_nom then
                    w_couche_trouvee = TRUE
                end if
            next
            if (w_couche_trouvee = FALSE) then
                add map window id_map_win layer w_nom
            end if
        end if
    end if

end sub
_____________________________________________________________________________________________________________________
'=====================================================================================================================
'Menu Nouvelle table cadastrale
'=====================================================================================================================
sub boite_cadastre

    call lst_choix_dep
    'call lst_choix_commune

    dialog
        width 290
        height 320
        position 250,50
        title "Cadastre"

        control okbutton
            id 1
            position 105,290 width 40 height 20
            title "Valider"
            calling valider_cadastre

        control cancelbutton
            id 2
            position 155,290 width 40 height 20
            title "Annuler"
            calling annuler_cadastre

        control GroupBox
            id 3
            position 5,10 width 280 height 80
            title "Choix du département:"

        control listbox
            ID 4
            position 10,25 width 100 height 55
            title from variable tab_dep
            value  1

        control button
            id 5
            position 150,45 width 20 height 15
            title ">>"
            calling ajout_dep

        control button
            id 6
            position 120,45 width 20 height 15
            title "<<"
            calling del_dep

        control button
            id 101
            position 130,65 width 30 height 15
            title "ok"
            calling selection_com

        control listbox
            ID 7
            position 180,25 width 100 height 55
            title from variable tab_dep_choisit
            value  1

        control GroupBox
            id 8
            position 5,95 width 280 height 190
            title "Choix de la commune:"
            disable

        control  statictext
            id 9
            position 10,105 width 75 height 15
            title "Recherche"
            disable

        control edittext
            id 10
            position 90,105 width 100 height 15
            disable

        control button
            id 12
            position 200,105 width 30 height 15
            title "OK"
            calling recherche_com
            disable

        control listbox
            ID 11
            position 10,125 width 100 height 150
            title from variable tab_com
            value  1
            disable

        control button
            id 13
            position 150,140 width 20 height 15
            title ">>"
            calling ajout_commune
            disable

        control button
            id 14
            position 120,140 width 20 height 15
            title "<<"
            calling del_commune
            disable

        control listbox
            ID 15
            position 180,125 width 100 height 150
            title from variable tab_com_choisit
            value  1
            disable

end sub
___________________________________________________________________________________________________________________
sub valider_cadastre

    call boite_proprietaire

    redim tab_com(0)
    redim tab_dep_choisit(0)

end sub
___________________________________________________________________________________________________________________
sub annuler_cadastre

    dialog
        width 100
        height 70
        position 350,200
        title "Quitter"

        control okbutton
            id 16
            position 10,45 width 30 height 20
            title "Valider"
            calling valider

        control button
            id 17
            position 60,45 width 30 height 20
            title "Annuler"
            calling boite_cadastre

        control statictext
            id 18
            position 10,10 width 75 height 30
            title "Etes-vous sur de vouloir quitter?"

end sub
___________________________________________________________________________________________________________________
sub valider

    redim tab_dep_choisit (0)
    nb_dep_choisit = 0
    'alter control 7 title from variable tab_dep_choisit

    redim tab_com (0)

    redim tab_com_choisit (0)
    nb_com_choisit = 0
    'alter control 15 title from variable tab_com_choisit

    close table departement
    close table com_selectionne
    close table Selection

end sub
___________________________________________________________________________________________________________________
sub lst_choix_dep

dim i as integer

    REDIM tab_dep (Tableinfo (departement, TAB_INFO_NROWS))    'permet de redimensionner le tableau contenant la liste des départements

    nb_dep = Tableinfo (departement, TAB_INFO_NROWS)            'le nombre des départements

    fetch first from departement                                    'bouge sur le premier enregistrement de la table

    for i = 1 to nb_dep        
        tab_dep(i) = departement.col(2)                            'permet de sélectionner les intitulés de la deuxième colonne    
        fetch next from departement
    Next

end sub
___________________________________________________________________________________________________________________
sub ajout_dep

dim selection as string
dim select_ind as integer
dim trouve as logical
dim i as integer

    selection = ""
    select_ind = 0

    select_ind = readcontrolvalue(4)
    selection = tab_dep(select_ind)

    for i = 1 to nb_dep_choisit
        if selection = tab_dep_choisit(i) then
            trouve = true
        end if
    next    

    if trouve = FALSE then
        nb_dep_choisit = nb_dep_choisit + 1                            
        redim tab_dep_choisit(nb_dep_choisit)
        tab_dep_choisit(nb_dep_choisit) = selection
        alter control 7 title from variable tab_dep_choisit
    end if    

end sub
___________________________________________________________________________________________________________________
sub del_dep

dim selection as string
dim select_ind as integer

    selection = ""
    select_ind = 0

    select_ind = readcontrolvalue(7)
    selection = tab_dep_choisit(select_ind)

    nb_dep_choisit = nb_dep_choisit - 1    
                        
    redim tab_dep_choisit(nb_dep_choisit)
    tab_dep_choisit(nb_dep_choisit) = selection

    alter control 7 title from variable tab_dep_choisit

end sub
___________________________________________________________________________________________________________________
sub selection_com

'dim i as integer

    'for i = 1 to nb_dep
        'select * from INSSEE where C = "tab_dep_choisit.col(3)"
        'fetch next from tab_dep_choisit
    'next

    'call lst_choix_commune

dim i as integer
dim y as integer
dim nom_dep as string

    if nb_dep_choisit <> 0 then

        for i = 1 to nb_dep_choisit

            nom_dep = tab_dep_choisit(i)

            'for y = 1 to nb_dep_choisit
                select * from INSSEE where C = nom_dep into com_selectionne        
            'next

        next

                'REDIM tab_com (Tableinfo (com_selectionne, TAB_INFO_NROWS))        

                'nb_com = Tableinfo (com_selectionne, TAB_INFO_NROWS)                    

                'fetch first from com_selectionne                                            

                'for i = 1 to nb_com        
                    'tab_com(i) = com_selectionne.col(1)                                    
                    'fetch next from com_selectionne
                'Next

    end if

    browse * from com_selectionne
    alter control 11 title from variable tab_com

    alter control 8 enable
    alter control 9 enable
    alter control 10 enable
    alter control 11 enable
    alter control 12 enable
    alter control 13 enable
    alter control 14 enable
    alter control 15 enable

end sub

Dernière modification par lina145 (Mon 07 June 2010 17:08)

Hors ligne

 

#8 Mon 07 June 2010 17:13

Spacejo
Membre
Lieu: Nancy
Date d'inscription: 17 Aug 2008
Messages: 2511

Re: [MapBasic 6.5] plusieurs sélection dans une liste

Si tu veux incrémenter ta sélection avoir alier+Cantal, ne faut il pas utiliser un "noselect"
En sachant que selection est un nom utiliser par mapinfo.

Hors ligne

 

#9 Mon 07 June 2010 17:54

lina145
Juste Inscrit !
Date d'inscription: 7 Jun 2010
Messages: 5

Re: [MapBasic 6.5] plusieurs sélection dans une liste

J'ai essayé la solution avec le noselect mais cela ne marche toujours pas. J'ai mis un note dans la boucle pour voir si elle faisait bien le tour de tout les enregistrement et elle le fait bien.

Comme vous le dite elle doit écraser la sélection précédente. Mais je n'arrive pas à trouver comment faire pour mettre  deux sélection ou plus dans une listbox.

Hors ligne

 

Pied de page des forums

Powered by FluxBB