Jump to content

Recommended Posts

Posted

hi i am new in autoit and i am trying to create a GUI that includes a listview to display data from a a SQL select but i need to give the user the posibility to choose a value from a combobox in order to proces that data updating a table in SQL for this i would need to add a combobox with the choices in the listview value or is there other way to do it? thankyou in advanced any help would be great.

Posted (edited)
#include <WinAPILocale.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>
#include <String.au3>


;~ global  $test = "esta,es,una,cadena"
$www=0

$constrim="DRIVER={SQL Server};SERVER=server;DATABASE=database;uid=user;pwd=password;"
$adCN = ObjCreate ("ADODB.Connection") ; <== Create SQL connection
$adCN.Open ($constrim) ; <== Connect with required credentials
$registros = "SELECT top(1)  COUNT(*) OVER () AS TotalRecords FROM BI_T431 INNER JOIN BI_T125 ON BI_T125.rowid_item_ext=BI_T431.f_rowid_item_ext AND BI_T125.parametro_biable = '1' where BI_T431.f_id_tipo_docto = 'pw' and  f_estado_docto = 'Cumplido' group by f_id_tipo_docto,f_nrodocto,f_cargue,f_cliente_fact"
$query4="SELECT f_co,f_id_tipo_docto , f_nrodocto,sum(f_valor_neto_docto) as valor,f_cargue,(select f200_razon_social from t200_mm_terceros  where f200_nit = f_cliente_fact) as cliente FROM BI_T431 INNER JOIN BI_T125 ON BI_T125.rowid_item_ext=BI_T431.f_rowid_item_ext AND BI_T125.parametro_biable = '1' where BI_T431.f_id_tipo_docto = 'pw' and  f_estado_docto = 'Cumplido' group by f_id_tipo_docto,f_nrodocto,f_cargue,f_cliente_fact,f_co"
;~ $result5 = $adCN.Execute($query5)
$num_registros = $adCN.Execute($registros)
$TotalRecords = $num_registros.Fields("TotalRecords").value
$result4 = $adCN.Execute($query4)

Dim $item[$TotalRecords]
Dim $test = "esta,es,una,cadena"
Dim $pedido[10]
GUICreate("listview items", 700, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)

$listview = GUICtrlCreateListView("tipo documento|num documento|Cliente| Cargue|Valor|Centro de Operaciones", 10, 10, 680, 150, -1, $LVS_EX_CHECKBOXES)
$button = GUICtrlCreateButton("Documentos a procesar?", 75, 170, 170, 20)

 While NOT $result4.EOF ; hace el bucle hasta que llegue al final de la consulta del select
    ;=>> aqui alguna función que haga algo con los datos la manipulas como texto,
    ;=>> recuperas el valor de las variables/campos user y telefono con->
$item[$www] = GUICtrlCreateListViewItem($result4.Fields("f_id_tipo_docto").value & "|" & $result4.Fields("f_nrodocto").value  & "|" & $result4.Fields("cliente").value & "|" & $result4.Fields("f_cargue").value & "|" & (_WinAPI_GetNumberFormat(0, ceiling($result4.Fields("valor").value), _WinAPI_CreateNumberFormatInfo(0, 1, 3, '', ',', 1))&"|"& $result4.Fields("f_co").value & @CRLF) , $listview)
$www=$www+1
   $result4.MoveNext ; mueve al siguiente registro del select
 WEnd
 GUISetState()


Do
 $msg = GUIGetMsg()

 Select
  Case $msg = $button
   For $x = 1 To $TotalRecords
    If _GUICtrlListView_GetItemChecked($listview, $x - 1) Then
        Local $pedido = _StringExplode(_GUICtrlListView_GetItemTextString($listview, $x - 1), "|", 0)
;~         $pedido = StringSplit(_GUICtrlListView_GetItemTextString($listview, $x - 1),"|")
     MsgBox(0, "listview item", $pedido[3] &"= este fue el test" , 2)
;~      MsgBox(0, "listview item", _GUICtrlListView_GetItemTextString($listview, $x - 1) & "    " & @CRLF & "nombre usuario = " & $test, 2)
    EndIf
   Next
  Case $msg = $listview
   MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
 EndSelect
Until $msg = $GUI_EVENT_CLOSE

now i need to add a combobox as a column to this

Edited by Melba23
Added code tags
  • Moderators
Posted

kstriyhon,

My GUIListViewEx UDF (look in my sig for the link) allows you to add combos to a ListView. Come back if you need help integrating the UDF with your script.

And In future when you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...