Jump to content

Recommended Posts

this is a really strange question, the program only makes a mistake if you didn't program it correctly. The standard functions that autoit uses are 99% bug free, so i think you should post your code so we can take a look what the problem might be.

Link to comment
Share on other sites

  • Moderators

ahmed9100,

is there any chance that make the script make a mistake ?

The script does not make mistakes - it does exactly what the coder has told it to do! ;)

But the coder may well have made mistakes and so it is a good idea to put errorchecking code in the script to try and catch any errors.

For example, are you expecting an array to be returned from a function? Best check that you have an array before trying to address the individual elements or you get a error.

Are you opening a file? You need to check the file actually opened before trying to read/write it.

And so on.......

Have you run the script many, many times to check for errors? Have you used the Tidy and Au3Check tools in the full version of SciTE (downloadable from here)?

You can never be totally sure that there are no bugs, but you can do your best to make sure that the code is a clean as you can get it. :blink:

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

 

Link to comment
Share on other sites

the script work very fine an i has no problem but i just ask to be sure so i can use it in my work

and here is the code

if anyone has a advice to make it better !

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SQLite.au3>
#include <GuiListView.au3>
#Include <Array.au3>
#Region ### START Koda GUI section ### Form=C:\Documents and Settings\EL-Zaeem\Desktop\مبيعات\sales.kxf
If Not FileExists(@ScriptDir & "\data\Accessories") Then
    DirCreate(@ScriptDir & "\data\Accessories")
EndIf
If Not FileExists(@ScriptDir & "\data\Bill") Then
    DirCreate(@ScriptDir & "\data\Bill")
EndIf
$Form1 = GUICreate("form1", 698, 554, 142, 120)
$List1 = GUICtrlCreateList("", 32, 88, 161, 435)
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
$hListView = GUICtrlCreateListView("Type|Count|Price|Note", 245, 248, 417, 279,-1,$iExListViewStyle)
_GUICtrlListView_SetColumnWidth($hListView, 0, 120)
_GUICtrlListView_SetColumnWidth($hListView, 1, 45)
_GUICtrlListView_SetColumnWidth($hListView, 2, 45)
_GUICtrlListView_SetColumnWidth($hListView, 3, 185)
$add = GUICtrlCreateButton("add", 544, 192, 97, 25, $WS_GROUP)
$delete = GUICtrlCreateButton("delete", 400, 192, 89, 25, $WS_GROUP)
$avilable = GUICtrlCreateInput("0", 360, 100, 33, 21,BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$lib = GUICtrlCreateLabel("available", 400, 103, 21, 25)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$count = GUICtrlCreateInput("0", 360, 120, 33, 21)
$Label1 = GUICtrlCreateLabel("count", 400, 123, 21, 17)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$close = GUICtrlCreateButton("close", 264, 192, 81, 25, $WS_GROUP)
$type = GUICtrlCreateInput("", 424, 120, 161, 21,BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$Date = GUICtrlCreateInput(@MDAY & "," & @MON & "," & @YEAR, 620, 8, 70, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$Label2 = GUICtrlCreateLabel("type", 600, 123, 32, 17)
$Label44 = GUICtrlCreateLabel("date", 565, 10, 50, 21)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Label3 = GUICtrlCreateLabel("price", 320, 123, 30, 17)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$price = GUICtrlCreateInput("", 264, 120, 49, 21,BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$note = GUICtrlCreateInput("", 264, 160, 321, 21)
$Label4 = GUICtrlCreateLabel("note", 592, 160, 42, 17)
GUICtrlSetBkColor(-1, 0xD4D0C8)
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\sales.jpg", 0, 0, 697, 553, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
    _GUICtrlListView_RegisterSortCallBack($hListView, False)
fill()
filldata()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            save()
            Exit
        Case $hListView
            _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))
            $getcount = _GUICtrlListView_GetItemCount($hListView)
            $i = 0
            Do
            $1 = _GUICtrlListView_GetItemText($hListView, $i)
            $2 = _GUICtrlListView_GetItemText($hListView, $i,1)
            $3 = _GUICtrlListView_GetItemText($hListView, $i,2)
            $4 = _GUICtrlListView_GetItemText($hListView, $i,3)
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data",$i,$1 & "*" & $2 & "*" & $3 & "*" & $4)
            $i = $i + 1
            Until $i = $getcount
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data","datacount",$getcount)
        case $list1
            $selected = _GUICtrlListBox_GetCurSel($List1)
            fillstat($selected)
            if GUICtrlRead($avilable) = "0" Then
                GUICtrlSetBkColor($avilable, 0xFF0000)
            Else
                GUICtrlSetBkColor($avilable, 0xF1EFE2)
            EndIf
        case $add
            if GUICtrlRead($type) = "" or GUICtrlRead($type) = "0" Then
            MsgBox(4160, "Information", "Please Chose a prodact")
            Else
            if Int(GUICtrlRead($count)) > Int(GUICtrlRead($avilable)) Then
                MsgBox(4160, "Information", "Not enough product")
            Else
            if GUICtrlRead($count) = 0 Then
                MsgBox(4160, "Information", "Please Enter count number")
            Else
            $selected1 = _GUICtrlListBox_GetCurSel($List1)
            $loz = _GUICtrlListBox_GetText($List1, $selected1)
            $11 = IniRead(@ScriptDir & "\data\Accessories\" & $loz & ".ini","data","count","0")
            $newdate2 = $11 - GUICtrlRead($count)
            IniWrite(@ScriptDir & "\data\Accessories\" & $loz & ".ini","data","count",$newdate2)
            GUICtrlSetData($avilable,$newdate2)
            if GUICtrlRead($avilable) = "0" Then
                GUICtrlSetBkColor($avilable, 0xFF0000)
            Else
                GUICtrlSetBkColor($avilable, 0xF1EFE2)
            EndIf
            $getcount = _GUICtrlListView_GetItemCount($hListView)
            $getcount2 = $getcount + 1
            $lastprice = GUICtrlRead($price) * GUICtrlRead($count)
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data","datacount",$getcount2)
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data",$getcount,GUICtrlRead($type) & "*" & GUICtrlRead($count) & "*" & $lastprice & "*" & GUICtrlRead($note))
            filldata()
            EndIf
            EndIf
        EndIf
        case $delete
            $selected = _GUICtrlListView_GetSelectionMark($hListView)
            $1 = _GUICtrlListView_GetItemText($hListView, $selected)
            $2 = _GUICtrlListView_GetItemText($hListView, $selected,1)
            $23 = IniRead(@ScriptDir & "\data\Accessories\" & $1 & ".ini","data","count","0")
            $getback = $23 + $2
            IniWrite(@ScriptDir & "\data\Accessories\" & $1 & ".ini","data","count",$getback)
            $1o = IniRead(@ScriptDir & "\data\Accessories\" & $1 & ".ini","data","count","0")

            $z1 = _GUICtrlListBox_GetCurSel($List1)
            $z2 = _GUICtrlListBox_GetText($List1, $z1)

            If $z2 = $1 Then
            GUICtrlSetData($avilable,$1o)
            EndIf
            _GUICtrlListView_DeleteItem($hListView, $selected)
            save()
        Case $close
            save()
            Exit
    EndSwitch
WEnd
Func fillstat($num)
$loz = _GUICtrlListBox_GetText($List1, $num)
$1 = IniRead(@ScriptDir & "\data\Accessories\" & $loz & ".ini","data","type","0")
$2 = IniRead(@ScriptDir & "\data\Accessories\" & $loz & ".ini","data","sel","0")
$3 = IniRead(@ScriptDir & "\data\Accessories\" & $loz & ".ini","data","count","0")
GUICtrlSetData($type,$1)
GUICtrlSetData($price,$2)
GUICtrlSetData($avilable,$3)
EndFunc
Func fill()
$member=_FileListToArray(@ScriptDir & "\data\Accessories")
If @Error Then
    MsgBox (0,"","No data Found.")
    Else
$filecount = $member[0]
if $filecount = "0" Then
    Else
    $i = 0
    Do
    $i = $i + 1
        $name1 = IniRead(@ScriptDir & "\data\Accessories\" &$member[$i] ,"data","type","Error")
        _GUICtrlListBox_InsertString($List1, $name1, 0)
    Until $i = $filecount
EndIf
EndIf
EndFunc
Func filldata()
            _GUICtrlListView_DeleteAllItems($hListView)
            $DCount = IniRead(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data","datacount","Error")
            if $DCount = "Error" or $DCount = "0" Then
            Else
            $i = 0
            Do
            $data = IniRead(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data",$i,"0")
            $finaldata = StringSplit($data,"*")
            GUICtrlCreateListViewItem($finaldata[1] &"|"& $finaldata[2] &"|"& $finaldata[3] & "|"& $finaldata[4], $hListView)
            $i = $i + 1
            Until $i = $DCount
            EndIf
EndFunc

Func save()
            $getcount = _GUICtrlListView_GetItemCount($hListView)
            if $getcount = "0" Then
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data","datacount","0")
            Else
            $i = 0
            Do
            $1 = _GUICtrlListView_GetItemText($hListView, $i)
            $2 = _GUICtrlListView_GetItemText($hListView, $i,1)
            $3 = _GUICtrlListView_GetItemText($hListView, $i,2)
            $4 = _GUICtrlListView_GetItemText($hListView, $i,3)
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data",$i,$1 & "*" & $2 & "*" & $3 & "*" & $4)
            $i = $i + 1
            Until $i = $getcount
            IniWrite(@ScriptDir & "\data\Bill\" & GUICtrlRead($Date) & ".ini","data","datacount",$getcount)
            EndIf
EndFunc

post-36280-12785865675142_thumb.jpg

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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