Code : Tout sélectionner
#include <GuiConstantsEx.au3>
#include <ListviewConstants.au3>
#include <Array.au3>
Dim $array[3][4]
$array[0][1] = "20"
$array[1][1] = "40"
$array[2][1] = "50"
$array[0][2] = "7.50"
$array[1][2] = "12"
$array[2][2] = "17"
$Form1 = GUICreate("Form1", 840, 250, 199, 127)
Global $Date1 = GUICtrlCreateDate("", 10, 10, 201, 25)
$date2 = GUICtrlRead ($Date1)
$listview = GUICtrlCreateListView("désignation| en stock|prix|"&$date2&"|", 10, 50, 400, 130)
GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, 100)
;GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 20, 200)
$listview1 = GUICtrlCreateListView("désignation|prix ht|TVA %|nombres|Prix total ", 430, 50, 400, 130)
GUICtrlSendMsg($listview1, $LVM_SETCOLUMNWIDTH, 0, 100)
$total = GUICtrlCreateInput("", 658, 192, 172, 21)
GUISetState(@SW_SHOW)
Dim $lignetab1[3]
$lignetab1[0] = GUICtrlCreateListViewItem("assiette 18x18|" &$array[0][1] & "|" & $array[0][2], $listview)
$lignetab1[1] = GUICtrlCreateListViewItem("vers a vin|" &$array[1][1] & "|" & $array[1][2], $listview)
$lignetab1[2] = GUICtrlCreateListViewItem("couteaux|" &$array[2][1] & "|" & $array[2][2], $listview)
$btn = GUICtrlCreateButton("ajouter au second tableau", 428, 190, 150, 25)
$btn1 = GUICtrlCreateButton("retirez du stock", 580, 190, 60, 25)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btn
$prix_total = GuiCtrlRead($total)
$index = ControlListView ($Form1, "", $listview, "GetSelected")
$produit = ControlListView ($Form1, "", $listview, "GetText", $index, 0)
$prix = ControlListView ($Form1, "", $listview, "GetText", $index, 2)
$nb = InputBox("Question", "combien d'article voulez vous ajouter ?")
$prix = $nb*$prix
$newitem = $produit & "| | | " & $nb & "|" & StringFormat("%.2f", $prix)
GUICtrlCreateListViewItem($newitem, $listview1)
GuiCtrlSetData($total, StringFormat("%.2f", $prix_total + $prix))
$array[$index][1] = $array[$index][1] - $nb
GuiCtrlSetData($lignetab1[$index], "|" & $array[$index][1])
Case $btn1
_devis_ini()
Case $Date1
GuiCtrlSetData($listview, "|||" & GUICtrlRead($Date1))
EndSwitch
WEnd
#cs
Func _devis_ini()
$inifile = @ScriptDir&"\"&"devis.ini"
$count = ControlListView($Form1, "", $listview1, "GetItemCount")
For $i = 0 To $count-1
$ini_produit = ControlListView($Form1, "", $listview1, "GetText", $i, 0)
$ini_qte = ControlListView($Form1, "", $listview1, "GetText", $i, 3)
$ini_prix = ControlListView($Form1, "", $listview1, "GetText", $i, 4)
IniWrite($inifile, $ini_produit, $ini_qte, $ini_prix )
Next
IniWrite($inifile, "total", "montant", GUICtrlRead($total))
EndFunc
#ce
Func _devis_ini()
$inifile = @ScriptDir&"\"&"devis.ini"
$client = "client1"
$count = ControlListView($Form1, "", $listview1, "GetItemCount")
IniWrite($inifile, $client, "date", GUICtrlRead($Date1))
For $i = 0 To $count-1
$ini_produit = ControlListView($Form1, "", $listview1, "GetText", $i, 0)
$ini_qte = ControlListView($Form1, "", $listview1, "GetText", $i, 3)
$ini_prix = ControlListView($Form1, "", $listview1, "GetText", $i, 4)
IniWrite($inifile, $client, $ini_qte & " " & $ini_produit, $ini_prix )
Next
IniWrite($inifile, $client, "total", GUICtrlRead($total))
EndFunc