sábado, 21 de abril de 2012

Usando Listas en PowerBuilder

Agregando lista de productos en el open //Agregar Productos ddplb_producto.additem("Cocina",1) ddplb_producto.additem("DVD",1) ddplb_producto.additem("Lavadora",1) ddplb_producto.additem("Equipo",1) ddplb_producto.additem("Plancha",1) ddplb_producto.additem("Radio",1) ddplb_producto.additem("Refrigeradora",1) ddplb_producto.additem("Televisor",1) Luego en ddplb_producto hacemos la siguiente codificación long f //buscar si el articulo se encuentra f=plb_lista.finditem(ddplb_producto.text,0) if f > 0 then messagebox("Cuidado","El producto ya se agrego") else plb_lista.additem(ddplb_producto.text) end if //Agregar total de productos al st_productos st_productos.text = String(plb_lista.TotalItems()) Boton subir int f string texto f=plb_lista.selectedindex() texto=plb_lista.selecteditem() if f > 1 then plb_lista.deleteitem(f) f = f -1 plb_lista.insertitem(texto,f) else messagebox("Error","Seleccione un producto") end if Boton bajar int f string texto f=plb_lista.selectedindex() texto=plb_lista.selecteditem() if f > 0 then plb_lista.deleteitem(f) f = f + 1 plb_lista.insertitem(texto,f) else messagebox("Error","Seleccione un producto") end if Luego en el sle_buscar: long f f=plb_lista.finditem(sle_buscar.text,0) if f > 0 then plb_lista.selectitem(f) else messagebox("Cuidado","No se encuentra coincidencia") end if cbx_ordenar: if cbx_ordenar.checked=true then plb_lista.Sorted = TRUE else end if boton cb_borrarseleccionado long f f=plb_lista.selectedindex() if f > 0 then plb_lista.deleteitem(f) else messagebox("Error","Seleccione un Producto") end if st_productos.text=String(plb_lista.totalitems()) boton cb_borrarultimo plb_lista.deleteitem(plb_lista.totalitems( ) ) st_productos.text=string(plb_lista.totalitems( )) boton cb_limpiar plb_lista.reset( ) st_productos.text=""