/* Items Client - DMS - jan 99 - by Sebastien DENEUX */ defcom CsupprimeElement = supprimeElement S S;; defcom CmajElement = majElement S S S S ;; defcom CajouteElement = ajouteElement S S S S;; defcom CdemandeInventaireClient = demandeInventaireClient S;; typeof winEdition = ObjWin;; typeof liste = ObjListTab;; typeof posCourante = I;; /*current position in the list*/ typeof mesElements = [[S r1] r1];; /* [[S S S] r1]*/ typeof edit1 = ObjText;; typeof edit2 = ObjText;; typeof edit3 = ObjText;; typeof GOButton = ObjButton;; typeof editLoginEditTxt=ObjText;; typeof loginTxt=ObjText;; /*-----------*/ fun _end(s)= _DMSreleaseZone this "ZoneEdition";; /*-----------*/ /*add elements from myTyple in the listBox*/ fun ajouterElementsListeBox(Mytuple)= if Mytuple!=nil then let Mytuple -> [[premierElement[secondElement[troisiemeElement _]]] suite] in (_ADDlistTabItem liste 0 0 premierElement; _SETlistTabItem liste 0 1 secondElement; _SETlistTabItem liste 0 2 troisiemeElement; ajouterElementsListeBox suite) else 0;; /*-----------*/ fun clickGo(a,b)= _DMSsend this CdemandeInventaireClient [_GETtext b];; /*-----------*/ fun ajouterFinListe(l,new)= if l!=nil then (let l -> [d f] in if f==nil then d::new::nil else d::ajouterFinListe f new) else new::nil;; /*-----------*/ /*ADD*/ fun ajouterObjet (a,b)= let b -> [liste nomLogin] in let _GETtext edit1 -> Sedit1 in let _GETtext edit2 -> Sedit2 in let _GETtext edit3 -> Sedit3 in let _GETtext nomLogin -> SnomLogin in if ((strlen Sedit1)!=0 && (strlen Sedit2)!=0 && (strlen Sedit3)!=0) then if (atoi Sedit1)>=0 && (atoi Sedit3)>=0 then _DMSsend this CajouteElement [Sedit1 Sedit2 Sedit3 SnomLogin] else nil else nil;; /*-----------*/ fun __ajouteElementRetour(a)= if a==1 then (set mesElements = ajouterFinListe mesElements ((_GETtext edit1)::(_GETtext edit2)::(_GETtext edit3)::nil); _ADDlistTabItem liste 0 0 _GETtext edit1; _SETlistTabItem liste 0 1 _GETtext edit2; _SETlistTabItem liste 0 2 _GETtext edit3) else nil;; /*-----------*/ fun remove_nth_from_list (list, n)= if n < 0 then list else let list -> [first next] in if n==0 then next else first::remove_nth_from_list next n-1;; /*-----------*/ /*DELETE*/ fun supprimerObjet (a,b)= if posCourante!=-1 then let b -> [liste nomLogin] in let _GETtext edit1 -> Sedit1 in let _GETtext nomLogin -> SnomLogin in _DMSsend this CsupprimeElement [Sedit1 SnomLogin] /*delete in the database*/ else nil;; /*-----------*/ fun __supprimeElementRetour(a)= if a==1 then (set mesElements = remove_nth_from_list mesElements ((sizelist mesElements) - posCourante -1); /*efface l'element dans le tuple mesElements*/ _DELlistTabItem liste posCourante; /*delete current elements int the lisbox*/ set posCourante=-1) /*no more selection*/ else nil;; /*-----------*/ fun update_nth_in_list (list, n, x)= if n < 0 then list else let list -> [first next] in if n==0 then x::next else first::update_nth_in_list next n-1 x;; /*-----------*/ /*UPDATE*/ fun majObjet(a,b)= if posCourante!=-1 then let b -> [liste nomLogin] in let _GETtext edit1 -> Sedit1 in let _GETtext edit2 -> Sedit2 in let _GETtext edit3 -> Sedit3 in let _GETtext nomLogin -> SnomLogin in if (atoi Sedit1)>=0 && (atoi Sedit3)>=0 then _DMSsend this CmajElement [Sedit2 Sedit3 Sedit1 SnomLogin] else nil else nil;; /*-----------*/ fun __majElementRetour(a)= if a==1 then (set mesElements = update_nth_in_list mesElements ((sizelist mesElements) - posCourante -1) ((_GETtext edit1)::(_GETtext edit2)::(_GETtext edit3)::nil); _SETlistTabItem liste posCourante 1 _GETtext edit2; _SETlistTabItem liste posCourante 2 _GETtext edit3 ) else nil;; /*-----------*/ /*update the 3 edition zones when CB on list*/ fun majEdit(liste,b,pos)= let nth_list mesElements ((sizelist mesElements) - pos - 1) -> [element1[element2[element3 _]]] in (set posCourante = pos; _SETtext edit1 element1; _SETtext edit2 element2; _SETtext edit3 element3);; /*-----------*/ fun _resizeEditionAdmin(a,b)= let a -> [win x y w h] in (_SIZEtext edit1 w/3 25 x y+h-25; _SIZEtext edit2 w/3 25 x+w/3 y+h-25; _SIZEtext edit3 w/3 25 x+2*w/3 y+h-25; _SIZEbutton GOButton w/3 25 x+2*w/3 y; _SIZEtext editLoginEditTxt w/3 25 x+w/3 y; _SIZEtext loginTxt w/3 25 x y; _SIZElistTab liste w h-50 x y+25;0);; /*-----------*/ fun __editionAdmin()= let _DMSgetZone this "ZoneEdition" nil @_resizeEditionAdmin @_end -> [win x y w h] in if win==nil then nil else (set loginTxt = _CRtext _channel win x y w/3 25 ET_BORDER "Login : "; set edit1 = _CReditText _channel win x y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL ""; set edit2 = _CReditText _channel win x+w/3 y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL ""; set edit3 = _CReditText _channel win x+2*w/3 y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL+ET_NUMBER "0"; set editLoginEditTxt = _CReditText _channel win x+w/3 y w/3 25 ET_BORDER ""; let _CRmenu _channel win -> menu in (set liste=_CRlistTab _channel win x y+25 w h-50 LV_BORDER; _ADDlistTabColumn liste 0 w/3 ET_ALIGN_LEFT "refItem"; _ADDlistTabColumn liste 1 w/3 ET_ALIGN_LEFT "nameItem"; _ADDlistTabColumn liste 2 w/3 ET_ALIGN_LEFT "countItem"; _CBlistTabSelect liste @majEdit nil; /*update edit zone*/ _CBmenu (_APPitem _channel menu ME_ENABLED "Add") @ajouterObjet ([liste editLoginEditTxt]); _CBmenu (_APPitem _channel menu ME_ENABLED "Delete") @supprimerObjet ([liste editLoginEditTxt]); _CBmenu (_APPitem _channel menu ME_ENABLED "Update") @majObjet ([liste editLoginEditTxt]); _CBbutton (set GOButton=_CRbutton _channel win x+2*w/3 y w/3 25 nil "GO") @clickGo (editLoginEditTxt)));; /*-----------*/ fun _resizeEditionUser(a,b)= let a -> [win x y w h] in (_SIZEtext edit1 w/3 25 x y+h-25; _SIZEtext edit2 w/3 25 x+w/3 y+h-25; _SIZEtext edit3 w/3 25 x+2*w/3 y+h-25; _SIZElistTab liste w h-25 x y;0);; /*-----------*/ fun __editionUser(s) = let strextr unzip s -> s2 in let _DMSgetZone this "ZoneEdition" nil @_resizeEditionUser @_end -> [win x y w h] in (set edit1 = _CReditText _channel win x y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL ""; set edit2 = _CReditText _channel win x+w/3 y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL ""; set edit3 = _CReditText _channel win x+2*w/3 y+h-25 w/3 25 ET_BORDER+ET_AHSCROLL+ET_NUMBER "0"; let _CRmenu _channel win -> menu in (set liste=_CRlistTab _channel win x y w h-25 LV_BORDER; _ADDlistTabColumn liste 0 w/3 ET_ALIGN_LEFT "refItem"; _ADDlistTabColumn liste 1 w/3 ET_ALIGN_LEFT "nameItem"; _ADDlistTabColumn liste 2 w/3 ET_ALIGN_LEFT "countItem"; set mesElements = s2; ajouterElementsListeBox mesElements; /*add elements form mesElements in the listbox*/ _CBlistTabSelect liste @majEdit nil; /*update zone edit*/ _CBmenu (_APPitem _channel menu ME_ENABLED "Add") @ajouterObjet ([liste nil]); _CBmenu (_APPitem _channel menu ME_ENABLED "Delete") @supprimerObjet ([liste nil]); _CBmenu (_APPitem _channel menu ME_ENABLED "Update") @majObjet ([liste nil])));; /*-----------*/ /*space = ²¤²*/ fun replace_in_list (list, old, new)= if list==nil then nil else let list -> [first next] in (if !strcmp first old then new::next else first::replace_in_list next old new);; /*-----------*/ fun gererEspace(l)= if l!=nil then let l -> [tete queue] in let replace_in_list tete "²¤²" "" -> tete in tete::gererEspace queue else l;; /*-----------*/ fun __envoiInventaireClient(s)= let strextr unzip s -> s2 in let gererEspace s2 -> s2 in (_RSTlistTab liste; set mesElements = s2; ajouterElementsListeBox mesElements);; /*-----------*/ fun IniDMI(s)= _DMSevent this "in" nil nil;;