Jump to content

Butonla Input Temizleme


monika
 Share

Recommended Posts

arkadaşlar iki sorum daha olacak

[b]1.[/b] add kısmına tıkladığımızda resimde kırmızı icerisine almış olduğum yere otomatik sıradaki numarayı nasıl yazdırabilirim.(Yani bir sonraki numarayı)

[b]2.[/b] Arkadaşlar sorum şu rakamsal olarak sıralıyorum fakat atıyorum 6 numarayı silince 1 2 3 4 5 7 8 9 10 olarak sıralıyor örnektede 2 numaralı satır. Ben silme işlemini yaptıktan sonra tüm listedeki rakamları tekrar editlemesini ve 1 2 3 4 5 6 7 8 9 olarak yazmasını nasıl sağlarım. (aradaki 6 silinince liste otomatik 9 item dan oluşacak ve sıralamayı tekrar baştan kayıt edecek.)

[img]http://g1203.hizliresim.com/v/x/3wy0p.png[/img]

Edited by bmozdemir
Link to comment
Share on other sites

@blue_life


ilgili kod üstte olduğundan dolayı tekrar yazmamıştım neyse kusura bakmayın kod aşşağıdaki birde InventoryData.ini dosyasınıda koyuyorum.

[codebox]
#include <array.au3>
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $INI_FILE = $ScriptDir & "InventoryData.ini"
Global $BLUE_ARRAY
Global $i=1
Global $MainForm = GUICreate("Form1", 623, 442)
Global $ListView1 = GUICtrlCreateListView("Sıra|Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlSendMsg(-1, 4126, 2, 100)
GUICtrlSendMsg(-1, 4126, 3, 82)
GUICtrlSendMsg(-1, 4126, 4, 80)
GUICtrlSendMsg(-1, 4126, 5, 120)

_Update_ListView() ;ListView Güncelle

Global $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25)
Global $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25)
Global $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
_Add_Edit_AProduct()
Case $Button2
_Add_Edit_AProduct("Edit")
Case $Button3
_DeleteItem()
EndSwitch
WEnd

Func _READ_INI()
Local $RETURN_ARRAY[25][7] ;GCID,Product Code,Make,Model,Current Stock,Date Modified=
$RAD_ISName = IniReadSectionNames($INI_FILE)
If Not @error Then
For $i = 1 To $RAD_ISName[0]
If StringLeft($RAD_ISName[$i], 0) <> "" Then ContinueLoop

$RETURN_ARRAY[0][0] += 1
If UBound($RETURN_ARRAY, 1) <= $RETURN_ARRAY[0][0] Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 25][7]

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = StringStripWS(IniRead($INI_FILE, $RAD_ISName[$i], "Sıra", $RAD_ISName[$i]), 3)
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = IniRead($INI_FILE, $RAD_ISName[$i], "Product Code", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Make", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Model", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = IniRead($INI_FILE, $RAD_ISName[$i], "Current Stock", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][6] = IniRead($INI_FILE, $RAD_ISName[$i], "Date Modified", "")
Next
EndIf
If UBound($RETURN_ARRAY, 1) <> ($RETURN_ARRAY[0][0] + 1) Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 1][7]
Return $RETURN_ARRAY
EndFunc ;==>_READ_INI

Func _Update_ListView()
If IsArray($BLUE_ARRAY) = 0 Then
$BLUE_ARRAY = _READ_INI() ;Read_Ini_File
EndIf

For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][0] = -1 Then ContinueLoop
If $BLUE_ARRAY[$i][0] > 0 Then GUICtrlDelete($BLUE_ARRAY[$i][0])

$BLUE_ARRAY[$i][0] = GUICtrlCreateListViewItem($BLUE_ARRAY[$i][1] & "|" & $BLUE_ARRAY[$i][2] & "|" & $BLUE_ARRAY[$i][3] & _
"|" & $BLUE_ARRAY[$i][4] & "|" & $BLUE_ARRAY[$i][5] & "|" & $BLUE_ARRAY[$i][6], $ListView1)
Next
EndFunc ;==>_Update_ListView

Func _Add_Edit_AProduct($AType = "Add")
Local $GuiRead
Local $i, $No, $productCode, $make, $Deneme, $model, $currentStock, $dataModified

If $AType <> "Add" Then
$GuiRead = GUICtrlRead($ListView1)
If $GuiRead = 0 Then
MsgBox(48, "Error!", "Not select item!", 0, $MainForm)
SetError(1, 0, 0)
EndIf

If IsArray($BLUE_ARRAY) = 0 Or $GuiRead = 0 Then Return SetError(2, 0, 0)
$BLUE_ARRAY[0][1] = 0

For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
$BLUE_ARRAY[0][1] = $i
$No = $BLUE_ARRAY[$i][1]
$productCode = $BLUE_ARRAY[$i][2]
$make = $BLUE_ARRAY[$i][3]
$model = $BLUE_ARRAY[$i][4]
$currentStock = $BLUE_ARRAY[$i][5]
$dataModified = $BLUE_ARRAY[$i][6]
ExitLoop
EndIf
Next
If $BLUE_ARRAY[0][1] = 0 Then Return SetError(3, 0, 0)
EndIf

GUISetState(@SW_DISABLE, $MainForm)

Local $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218)
Local $aInput1 = GUICtrlCreateInput($productCode, 16, 24, 193, 21)
Local $aInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21)
Local $aInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21)
Local $aInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21)
Local $aInput5 = GUICtrlCreateInput($dataModified, 16, 184, 193, 21)
Local $aLabel1 = GUICtrlCreateLabel($i, 16, 1, 30, 16, 0x1000)
GUICtrlCreateLabel("Product Code", 224, 24, 69, 17)
GUICtrlCreateLabel("Make", 224, 64, 31, 17)
GUICtrlCreateLabel("Model", 224, 104, 33, 17)
GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17)
GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17)
Local $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25)
If $AType <> "Add" Then GUICtrlSetData($cButton3, "Edit Product")

GUISetState(@SW_SHOW, $Form2)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $cButton3
$productCode = StringStripWS(GUICtrlRead($aInput1), 3)
If $productCode = "" Then
MsgBox(48, "Error!", "Enter product Code", 0, $Form2)
GUICtrlSetState($aInput1, 256)
ContinueCase
EndIf

$make = StringStripWS(GUICtrlRead($aInput2), 3)
If $make = "" Then
MsgBox(48, "Error!", "Enter make", 0, $Form2)
GUICtrlSetState($make, 256)
ContinueCase
EndIf


$model = StringStripWS(GUICtrlRead($aInput3), 3)
If $model = "" Then
MsgBox(48, "Error!", "Enter model", 0, $Form2)
GUICtrlSetState($model, 256)
ContinueCase
EndIf

$currentStock = StringStripWS(GUICtrlRead($aInput4), 3)
If $currentStock = "" Then
MsgBox(48, "Error!", "Enter current stock ", 0, $Form2)
GUICtrlSetState($currentStock, 256)
ContinueCase
EndIf

$dataModified = StringStripWS(GUICtrlRead($aInput5), 3)

; -------------------------------
If $AType = "Add" Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][1] = $productCode Then
GUICtrlSetState($aInput1, 256)
MsgBox(0, "Error", "The product is already in the database")
ContinueCase
EndIf
Next
$BLUE_ARRAY[0][0] += 1
ReDim $BLUE_ARRAY[$BLUE_ARRAY[0][0] + 1][7]
$BLUE_ARRAY[0][1] = $BLUE_ARRAY[0][0]
EndIf

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][1] = $i
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][2] = $productCode
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][3] = $make
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][4] = $model
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][5] = $currentStock
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][6] = $dataModified

IniWrite($INI_FILE, "" & $i, "Product Code", $productCode)
IniWrite($INI_FILE, "" & $i, "Make", $make)
IniWrite($INI_FILE, "" & $i, "Model", $model)
IniWrite($INI_FILE, "" & $i, "Current Stock", $currentStock)
IniWrite($INI_FILE, "" & $i, "Date Modified", $dataModified)
ExitLoop
EndSwitch
WEnd
_Update_ListView()
GUISwitch($MainForm)
GUISetState(@SW_ENABLE, $MainForm)
GUIDelete($Form2)
EndFunc ;==>_Add_Edit_AProduct

Func _DeleteItem()
Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR
If $GuiRead <> 0 Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
GUICtrlDelete($BLUE_ARRAY[$i][0])
IniDelete("InventoryData.ini", "" & $BLUE_ARRAY[$i][1])
$BLUE_ARRAY[$i][0] = -1
ExitLoop
EndIf
Next
EndIf
EndFunc ;==>_DeleteItem
[/codebox]

[b]InventoryData.ini[/b]

[codebox]
[1]
Product Code=a
Make=a
Model=a
Current Stock=a
Date Modified=a
[2]
Product Code=b
Make=b
Model=b
Current Stock=b
Date Modified=b
[3]
Product Code=c
Make=c
Model=c
Current Stock=c
Date Modified=c
[4]
Product Code=d
Make=d
Model=d
Current Stock=d
Date Modified=d
[5]
Product Code=e
Make=e
Model=e
Current Stock=e
Date Modified=e
[6]
Product Code=f
Make=f
Model=f
Current Stock=f
Date Modified=f
[7]
Product Code=g
Make=g
Model=g
Current Stock=g
Date Modified=g
[8]
Product Code=h
Make=h
Model=h
Current Stock=h
Date Modified=h
[9]
Product Code=ı
Make=ı
Model=ı
Current Stock=ı
Date Modified=ı
[10]
Product Code=i
Make=i
Model=i
Current Stock=i
Date Modified=i
[/codebox]

Edited by bmozdemir
Link to comment
Share on other sites

@bmozdemir

Çok fazla bakmadım. Ama ufak ekler yaptım. Sen diğer kısımları kendine göre düzenlersin...
[codebox]#include <array.au3>
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $INI_FILE = $ScriptDir & "InventoryData.ini"
Global $BLUE_ARRAY
Global $i = 1
Global $MainForm = GUICreate("Form1", 623, 442)
Global $ListView1 = GUICtrlCreateListView("Sıra|Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlSendMsg(-1, 4126, 2, 100)
GUICtrlSendMsg(-1, 4126, 3, 82)
GUICtrlSendMsg(-1, 4126, 4, 80)
GUICtrlSendMsg(-1, 4126, 5, 120)

_Update_ListView() ;ListView Güncelle

Global $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25)
Global $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25)
Global $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
_Add_Edit_AProduct()
Case $Button2
_Add_Edit_AProduct("Edit")
Case $Button3
_DeleteItem()
EndSwitch
WEnd

Func _READ_INI()
Local $RETURN_ARRAY[25][8] ;GCID,Product Code,Make,Model,Current Stock,Date Modified=
$RAD_ISName = IniReadSectionNames($INI_FILE)
If Not @error Then
For $i = 1 To $RAD_ISName[0]
If StringLeft($RAD_ISName[$i], 0) <> "" Then ContinueLoop

$RETURN_ARRAY[0][0] += 1
If UBound($RETURN_ARRAY, 1) <= $RETURN_ARRAY[0][0] Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 25][8]

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = $RETURN_ARRAY[0][0]
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = IniRead($INI_FILE, $RAD_ISName[$i], "Product Code", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Make", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Model", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = IniRead($INI_FILE, $RAD_ISName[$i], "Current Stock", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][6] = IniRead($INI_FILE, $RAD_ISName[$i], "Date Modified", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][7] = $RAD_ISName[$i]

Next
EndIf
If UBound($RETURN_ARRAY, 1) <> ($RETURN_ARRAY[0][0] + 1) Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 1][8]
Return $RETURN_ARRAY
EndFunc ;==>_READ_INI

Func _Update_ListView()
If IsArray($BLUE_ARRAY) = 0 Then
$BLUE_ARRAY = _READ_INI() ;Read_Ini_File
EndIf

Local $SIRA = 1
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][0] = -1 Then ContinueLoop
If $BLUE_ARRAY[$i][0] > 0 Then GUICtrlDelete($BLUE_ARRAY[$i][0])
$BLUE_ARRAY[$i][1] = $SIRA
$BLUE_ARRAY[$i][0] = GUICtrlCreateListViewItem($BLUE_ARRAY[$i][1] & "|" & $BLUE_ARRAY[$i][2] & "|" & $BLUE_ARRAY[$i][3] & _
"|" & $BLUE_ARRAY[$i][4] & "|" & $BLUE_ARRAY[$i][5] & "|" & $BLUE_ARRAY[$i][6], $ListView1)

$SIRA += 1
Next
EndFunc ;==>_Update_ListView

Func _Add_Edit_AProduct($AType = "Add")
Local $GuiRead
Local $i, $No, $productCode, $make, $Deneme, $model, $currentStock, $dataModified

If $AType <> "Add" Then
$GuiRead = GUICtrlRead($ListView1)
If $GuiRead = 0 Then
MsgBox(48, "Error!", "Not select item!", 0, $MainForm)
SetError(1, 0, 0)
EndIf

If IsArray($BLUE_ARRAY) = 0 Or $GuiRead = 0 Then Return SetError(2, 0, 0)
$BLUE_ARRAY[0][1] = 0

For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
$BLUE_ARRAY[0][1] = $i
$No = $BLUE_ARRAY[$i][1]
$productCode = $BLUE_ARRAY[$i][2]
$make = $BLUE_ARRAY[$i][3]
$model = $BLUE_ARRAY[$i][4]
$currentStock = $BLUE_ARRAY[$i][5]
$dataModified = $BLUE_ARRAY[$i][6]
ExitLoop
EndIf
Next
If $BLUE_ARRAY[0][1] = 0 Then Return SetError(3, 0, 0)
EndIf

GUISetState(@SW_DISABLE, $MainForm)

Local $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218)
Local $aInput1 = GUICtrlCreateInput($productCode, 16, 24, 193, 21)
Local $aInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21)
Local $aInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21)
Local $aInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21)
Local $aInput5 = GUICtrlCreateInput($dataModified, 16, 184, 193, 21)
Local $aLabel1 = GUICtrlCreateLabel($i, 16, 1, 30, 16, 0x1000)
GUICtrlCreateLabel("Product Code", 224, 24, 69, 17)
GUICtrlCreateLabel("Make", 224, 64, 31, 17)
GUICtrlCreateLabel("Model", 224, 104, 33, 17)
GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17)
GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17)
Local $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25)
If $AType <> "Add" Then GUICtrlSetData($cButton3, "Edit Product")

GUISetState(@SW_SHOW, $Form2)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $cButton3
$productCode = StringStripWS(GUICtrlRead($aInput1), 3)
If $productCode = "" Then
MsgBox(48, "Error!", "Enter product Code", 0, $Form2)
GUICtrlSetState($aInput1, 256)
ContinueCase
EndIf

$make = StringStripWS(GUICtrlRead($aInput2), 3)
If $make = "" Then
MsgBox(48, "Error!", "Enter make", 0, $Form2)
GUICtrlSetState($make, 256)
ContinueCase
EndIf


$model = StringStripWS(GUICtrlRead($aInput3), 3)
If $model = "" Then
MsgBox(48, "Error!", "Enter model", 0, $Form2)
GUICtrlSetState($model, 256)
ContinueCase
EndIf

$currentStock = StringStripWS(GUICtrlRead($aInput4), 3)
If $currentStock = "" Then
MsgBox(48, "Error!", "Enter current stock ", 0, $Form2)
GUICtrlSetState($currentStock, 256)
ContinueCase
EndIf

$dataModified = StringStripWS(GUICtrlRead($aInput5), 3)

; -------------------------------
If $AType = "Add" Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][1] = $productCode Then
GUICtrlSetState($aInput1, 256)
MsgBox(0, "Error", "The product is already in the database")
ContinueCase
EndIf
Next
$BLUE_ARRAY[0][0] += 1
ReDim $BLUE_ARRAY[$BLUE_ARRAY[0][0] + 1][8]
$BLUE_ARRAY[0][1] = $BLUE_ARRAY[0][0]
EndIf

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][1] = $i
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][2] = $productCode
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][3] = $make
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][4] = $model
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][5] = $currentStock
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][6] = $dataModified

IniWrite($INI_FILE, "" & $i, "Product Code", $productCode)
IniWrite($INI_FILE, "" & $i, "Make", $make)
IniWrite($INI_FILE, "" & $i, "Model", $model)
IniWrite($INI_FILE, "" & $i, "Current Stock", $currentStock)
IniWrite($INI_FILE, "" & $i, "Date Modified", $dataModified)

_Update_ListView()
ExitLoop
EndSwitch
WEnd
GUISwitch($MainForm)
GUISetState(@SW_ENABLE, $MainForm)
GUIDelete($Form2)
EndFunc ;==>_Add_Edit_AProduct

Func _DeleteItem()
Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR
If $GuiRead <> 0 Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
GUICtrlDelete($BLUE_ARRAY[$i][0])
IniDelete("InventoryData.ini", "" & $BLUE_ARRAY[$i][7])
$BLUE_ARRAY[$i][0] = -1
_Update_ListView()
ExitLoop
EndIf
Next
EndIf
EndFunc ;==>_DeleteItem[/codebox]

Link to comment
Share on other sites

@blue_life

evet elinize sağlık güzel olmuş fakat ini dosyası aradan bir dosya silindiğinde atıyorum 19'u sildiğimde lisview'de düzgün görüntülüyor fakat ini dosyası
19'u siliyor ve o numarayı es geçerek devam ediyor. Buda ini dosyasında karmaşa yaratıp sonraki kayıtları kayıt altına almıyor. Aslinda silme işleminden sonra listview'deki gibi komple ini dosyasını tekrar silip baştan oluşturamıyor muyuz acaba?

kodları göndermedim sizin son mesajınızda mevcut zaten bi değişiklik yapmadım işin aslı.

İlginize ve alakanız için tekrar minnettarım.

Link to comment
Share on other sites

@bmozdemir

_Update_ListView fonksiyonunda ini dosyasını silip yeniden yazabilirsin. Çok fazla inceleyemem kusura bakma.
Kısaca düzenlersek;

[codebox]#include <array.au3>
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $INI_FILE = $ScriptDir & "InventoryData.ini"
Global $BLUE_ARRAY
Global $i = 1
Global $MainForm = GUICreate("Form1", 623, 442)
Global $ListView1 = GUICtrlCreateListView("Sıra|Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlSendMsg(-1, 4126, 2, 100)
GUICtrlSendMsg(-1, 4126, 3, 82)
GUICtrlSendMsg(-1, 4126, 4, 80)
GUICtrlSendMsg(-1, 4126, 5, 120)

_Update_ListView() ;ListView Güncelle

Global $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25)
Global $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25)
Global $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
_Add_Edit_AProduct()
Case $Button2
_Add_Edit_AProduct("Edit")
Case $Button3
_DeleteItem()
EndSwitch
WEnd

Func _READ_INI()
Local $RETURN_ARRAY[25][8] ;GCID,Product Code,Make,Model,Current Stock,Date Modified=
$RAD_ISName = IniReadSectionNames($INI_FILE)
If Not @error Then
For $i = 1 To $RAD_ISName[0]
If StringLeft($RAD_ISName[$i], 0) <> "" Then ContinueLoop

$RETURN_ARRAY[0][0] += 1
If UBound($RETURN_ARRAY, 1) <= $RETURN_ARRAY[0][0] Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 25][8]

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = $RETURN_ARRAY[0][0]
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = IniRead($INI_FILE, $RAD_ISName[$i], "Product Code", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Make", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Model", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = IniRead($INI_FILE, $RAD_ISName[$i], "Current Stock", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][6] = IniRead($INI_FILE, $RAD_ISName[$i], "Date Modified", "")
$RETURN_ARRAY[$RETURN_ARRAY[0][0]][7] = $RAD_ISName[$i]
Next
EndIf
If UBound($RETURN_ARRAY, 1) <> ($RETURN_ARRAY[0][0] + 1) Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 1][8]
Return $RETURN_ARRAY
EndFunc ;==>_READ_INI

Func _Update_ListView()
Local $FileWrite = True
If IsArray($BLUE_ARRAY) = 0 Then
$BLUE_ARRAY = _READ_INI() ;Read_Ini_File
$FileWrite = False
EndIf

Local $SIRA = 1, $WriteData
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][0] = -1 Then ContinueLoop
If $BLUE_ARRAY[$i][0] > 0 Then GUICtrlDelete($BLUE_ARRAY[$i][0])
$BLUE_ARRAY[$i][1] = $SIRA
$BLUE_ARRAY[$i][0] = GUICtrlCreateListViewItem($BLUE_ARRAY[$i][1] & "|" & $BLUE_ARRAY[$i][2] & "|" & $BLUE_ARRAY[$i][3] & _
"|" & $BLUE_ARRAY[$i][4] & "|" & $BLUE_ARRAY[$i][5] & "|" & $BLUE_ARRAY[$i][6], $ListView1)


If $FileWrite = True Then $WriteData &= "[" & $BLUE_ARRAY[$i][1] & "]" & @LF & _
"Product Code=" & $BLUE_ARRAY[$i][2] & @LF & "Make=" & $BLUE_ARRAY[$i][2] & @LF & _
"Model=" & $BLUE_ARRAY[$i][2] & @LF & "Current Stock=" & $BLUE_ARRAY[$i][2] & @LF & _
"Date Modified=" & $BLUE_ARRAY[$i][2] & @LF & @LF

$SIRA += 1
Next

If $FileWrite = True Then
FileDelete($INI_FILE)
FileWrite($INI_FILE,$WriteData)
EndIf

EndFunc ;==>_Update_ListView

Func _Add_Edit_AProduct($AType = "Add")
Local $GuiRead
Local $i, $No, $productCode, $make, $Deneme, $model, $currentStock, $dataModified

If $AType <> "Add" Then
$GuiRead = GUICtrlRead($ListView1)
If $GuiRead = 0 Then
MsgBox(48, "Error!", "Not select item!", 0, $MainForm)
SetError(1, 0, 0)
EndIf

If IsArray($BLUE_ARRAY) = 0 Or $GuiRead = 0 Then Return SetError(2, 0, 0)
$BLUE_ARRAY[0][1] = 0

For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
$BLUE_ARRAY[0][1] = $i
$No = $BLUE_ARRAY[$i][1]
$productCode = $BLUE_ARRAY[$i][2]
$make = $BLUE_ARRAY[$i][3]
$model = $BLUE_ARRAY[$i][4]
$currentStock = $BLUE_ARRAY[$i][5]
$dataModified = $BLUE_ARRAY[$i][6]
ExitLoop
EndIf
Next
If $BLUE_ARRAY[0][1] = 0 Then Return SetError(3, 0, 0)
EndIf

GUISetState(@SW_DISABLE, $MainForm)

Local $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218)
Local $aInput1 = GUICtrlCreateInput($productCode, 16, 24, 193, 21)
Local $aInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21)
Local $aInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21)
Local $aInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21)
Local $aInput5 = GUICtrlCreateInput($dataModified, 16, 184, 193, 21)
Local $aLabel1 = GUICtrlCreateLabel($i, 16, 1, 30, 16, 0x1000)
GUICtrlCreateLabel("Product Code", 224, 24, 69, 17)
GUICtrlCreateLabel("Make", 224, 64, 31, 17)
GUICtrlCreateLabel("Model", 224, 104, 33, 17)
GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17)
GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17)
Local $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25)
If $AType <> "Add" Then GUICtrlSetData($cButton3, "Edit Product")

GUISetState(@SW_SHOW, $Form2)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
ExitLoop
Case $cButton3
$productCode = StringStripWS(GUICtrlRead($aInput1), 3)
If $productCode = "" Then
MsgBox(48, "Error!", "Enter product Code", 0, $Form2)
GUICtrlSetState($aInput1, 256)
ContinueCase
EndIf

$make = StringStripWS(GUICtrlRead($aInput2), 3)
If $make = "" Then
MsgBox(48, "Error!", "Enter make", 0, $Form2)
GUICtrlSetState($make, 256)
ContinueCase
EndIf


$model = StringStripWS(GUICtrlRead($aInput3), 3)
If $model = "" Then
MsgBox(48, "Error!", "Enter model", 0, $Form2)
GUICtrlSetState($model, 256)
ContinueCase
EndIf

$currentStock = StringStripWS(GUICtrlRead($aInput4), 3)
If $currentStock = "" Then
MsgBox(48, "Error!", "Enter current stock ", 0, $Form2)
GUICtrlSetState($currentStock, 256)
ContinueCase
EndIf

$dataModified = StringStripWS(GUICtrlRead($aInput5), 3)

; -------------------------------
If $AType = "Add" Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $BLUE_ARRAY[$i][1] = $productCode Then
GUICtrlSetState($aInput1, 256)
MsgBox(0, "Error", "The product is already in the database")
ContinueCase
EndIf
Next
$BLUE_ARRAY[0][0] += 1
ReDim $BLUE_ARRAY[$BLUE_ARRAY[0][0] + 1][8]
$BLUE_ARRAY[0][1] = $BLUE_ARRAY[0][0]
EndIf

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][1] = $i
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][2] = $productCode
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][3] = $make
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][4] = $model
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][5] = $currentStock
$BLUE_ARRAY[$BLUE_ARRAY[0][1]][6] = $dataModified

IniWrite($INI_FILE, "" & $i, "Product Code", $productCode)
IniWrite($INI_FILE, "" & $i, "Make", $make)
IniWrite($INI_FILE, "" & $i, "Model", $model)
IniWrite($INI_FILE, "" & $i, "Current Stock", $currentStock)
IniWrite($INI_FILE, "" & $i, "Date Modified", $dataModified)

_Update_ListView()
ExitLoop
EndSwitch
WEnd
GUISwitch($MainForm)
GUISetState(@SW_ENABLE, $MainForm)
GUIDelete($Form2)
EndFunc ;==>_Add_Edit_AProduct

Func _DeleteItem()
Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR
If $GuiRead <> 0 Then
For $i = 1 To $BLUE_ARRAY[0][0]
If $GuiRead = $BLUE_ARRAY[$i][0] Then
GUICtrlDelete($BLUE_ARRAY[$i][0])
IniDelete("InventoryData.ini", "" & $BLUE_ARRAY[$i][7])
$BLUE_ARRAY[$i][0] = -1
_Update_ListView()
ExitLoop
EndIf
Next
EndIf
EndFunc ;==>_DeleteItem[/codebox]

Edited by blue_life
Link to comment
Share on other sites

  • 2 years yıl...

Arkadaşlar verdiğiniz örnekleri kendime göre düzenledim ama ListView'e eklenenleri silip programı kapatıp açtığımda hala silinmemiş görünüyor.nerde hata var yardımcı olabilir misiniz?.
 

Kodlar:

[spoiler]


#include <array.au3>

DirCreate(@ProgramFilesDir & "\programklasor")

Global $ProgramFilesDir = @ProgramFilesDir

If StringRight($ProgramFilesDir, 1) <> "\" Then $ProgramFilesDir &= "\"

Global $INI_FILE = $ProgramFilesDir & "\programklasor\musteri.ini"

Global $BLUE_ARRAY

Global $i = 1

Global $MainForm = GUICreate("Ekle Düzenle", 836, 443)

Global $ListView1 = GUICtrlCreateListView("Müşteri Adı|Albüm Çeşitleri|Toplam Ücret|Alınan Ücret|Kalan Ücret|Tarih", 16, 8, 666, 390)

GUICtrlSendMsg(-1, 4126, 0, 150)

GUICtrlSendMsg(-1, 4126, 1, 110)

GUICtrlSendMsg(-1, 4126, 2, 100)

GUICtrlSendMsg(-1, 4126, 3, 100)

GUICtrlSendMsg(-1, 4126, 4, 100)

GUICtrlSendMsg(-1, 4126, 5, 100)



_Update_ListView() ;Update ListView



Global $Button1 = GUICtrlCreateButton("Ekle", 16, 408, 91, 25)

Global $Button2 = GUICtrlCreateButton("Düzenle", 120, 408, 91, 25)

Global $Button3 = GUICtrlCreateButton("Sil", 224, 408, 107, 25)

GUISetState(@SW_SHOW)



While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case -3

Exit

Case $Button1

_Add_Edit_AProduct()

Case $Button2

_Add_Edit_AProduct("Edit")

Case $Button3

_DeleteItem()

EndSwitch

WEnd



Func _READ_INI()

Local $RETURN_ARRAY[25][7] ;GCID,Product Code,Make,Model,Current Stock,Date Modified=

$RAD_ISName = IniReadSectionNames($INI_FILE)

If Not @error Then

For $i = 1 To $RAD_ISName[0]

If StringLeft($RAD_ISName[$i], 8) <> "Musteri_" Then ContinueLoop



$RETURN_ARRAY[0][0] += 1

If UBound($RETURN_ARRAY, 1) <= $RETURN_ARRAY[0][0] Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 25][8]



$RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = StringStripWS(IniRead($INI_FILE, $RAD_ISName[$i], "Müşteri Adı", ""), 3)

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = IniRead($INI_FILE, $RAD_ISName[$i], "Albüm Çeşidi", "")

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Toplam Ücret", "")

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Alınan Ücret", "")

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = IniRead($INI_FILE, $RAD_ISName[$i], "Kalan Ücret", "")

$RETURN_ARRAY[$RETURN_ARRAY[0][0]][6] = IniRead($INI_FILE, $RAD_ISName[$i], "Tarih", "")

Next

EndIf

If UBound($RETURN_ARRAY, 1) <> ($RETURN_ARRAY[0][0] + 1) Then ReDim $RETURN_ARRAY[$RETURN_ARRAY[0][0] + 1][8]

Return $RETURN_ARRAY

EndFunc ;==>_READ_INI



Func _Update_ListView()

If IsArray($BLUE_ARRAY) = 0 Then

$BLUE_ARRAY = _READ_INI() ;Read_Ini_File

EndIf

_ArraySort($BLUE_ARRAY, 0, 1, 0, 1)



For $i = 1 To $BLUE_ARRAY[0][0]

If $BLUE_ARRAY[$i][0] = -1 Then ContinueLoop

If $BLUE_ARRAY[$i][0] > 0 Then GUICtrlDelete($BLUE_ARRAY[$i][0])



$BLUE_ARRAY[$i][0] = GUICtrlCreateListViewItem($BLUE_ARRAY[$i][1] & "|" & $BLUE_ARRAY[$i][2] & "|" & $BLUE_ARRAY[$i][3] & _

"|" & $BLUE_ARRAY[$i][4] & "|" & $BLUE_ARRAY[$i][5] & "|" & $BLUE_ARRAY[$i][6], $ListView1)

If Number($BLUE_ARRAY[$i][4]) < 100 Then

GUICtrlSetBkColor($BLUE_ARRAY[$i][0], 0xfff333)

EndIf

If Number($BLUE_ARRAY[$i][4]) < 10 Then

GUICtrlSetBkColor($BLUE_ARRAY[$i][0], 0xff0000)

EndIf

Next

EndFunc ;==>_Update_ListView



Func _Add_Edit_AProduct($AType = "Add")

Local $GuiRead

Local $productCode, $make, $model, $currentStock, $kalan, $dataModified = @MON & "/" & @MDAY & "/" & @YEAR





If $AType <> "Add" Then

$GuiRead = GUICtrlRead($ListView1)

If $GuiRead = 0 Then

MsgBox(48, "Hata!", "Lütfen Bir Alan Seçiniz!", 0, $MainForm)

SetError(1, 0, 0)

EndIf



If IsArray($BLUE_ARRAY) = 0 Or $GuiRead = 0 Then Return SetError(2, 0, 0)

$BLUE_ARRAY[0][1] = 0



For $i = 1 To $BLUE_ARRAY[0][0]

If $GuiRead = $BLUE_ARRAY[$i][0] Then

$BLUE_ARRAY[0][1] = $i

$productCode = $BLUE_ARRAY[$i][1]

$make = $BLUE_ARRAY[$i][2]

$model = $BLUE_ARRAY[$i][3]

$currentStock = $BLUE_ARRAY[$i][4]

$kalan = $BLUE_ARRAY[$i][5]

$dataModified = $BLUE_ARRAY[$i][6]

ExitLoop

EndIf

Next

If $BLUE_ARRAY[0][1] = 0 Then Return SetError(3, 0, 0)

EndIf



GUISetState(@SW_DISABLE, $MainForm)



Local $Form2 = GUICreate("Ekleme Düzenleme", 320, 301)

Local $aInput1 = GUICtrlCreateInput($productCode, 16, 24, 193, 21)

Local $aInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21)

Local $aInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21)

Local $aInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21)

Local $aInput5 = GUICtrlCreateInput($kalan, 16, 184, 193, 21)

Local $aInput6 = GUICtrlCreateInput($dataModified, 14, 227, 193, 21)



GUICtrlCreateLabel("Müşteri Adı", 224, 24, 69, 17)

GUICtrlCreateLabel("Albüm Çeşidi", 224, 64, 69, 17)

GUICtrlCreateLabel("Toplam Ücret", 224, 104, 69, 17)

GUICtrlCreateLabel("Alınan Ücret", 224, 144, 69, 17)

GUICtrlCreateLabel("Kalan Ücret", 224, 184, 70, 17)

GUICtrlCreateLabel("Tarih", 222, 227, 70, 17)

Local $cButton3 = GUICtrlCreateButton("Tamam", 120, 264, 91, 25)

If $AType <> "Add" Then GUICtrlSetData($cButton3, "Düzenle")





GUISetState(@SW_SHOW, $Form2)



While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case -3

ExitLoop

Case $cButton3

$productCode = StringStripWS(GUICtrlRead($aInput1), 3)

If $productCode = "" Then

MsgBox(48, "Hata!", "Lütfen Müşteri Adı Ekleyin", 0, $Form2)

GUICtrlSetState($aInput1, 256)

ContinueCase

EndIf



$make = StringStripWS(GUICtrlRead($aInput2), 3)

If $make = "" Then

MsgBox(48, "Hata!", "Lütfen Albüm Çeşidi Ekleyin", 0, $Form2)

GUICtrlSetState($make, 256)

ContinueCase

EndIf





$model = StringStripWS(GUICtrlRead($aInput3), 3)

If $model = "" Then

MsgBox(48, "Hata!", "Lütfen Toplamı Ekleyin", 0, $Form2)

GUICtrlSetState($model, 256)

ContinueCase

EndIf







$currentStock = StringStripWS(GUICtrlRead($aInput4), 3)

If $currentStock = "" Then

MsgBox(48, "Hata!", "Lütfen Alınan Ücret Ekleyin", 0, $Form2)

GUICtrlSetState($currentStock, 256)

ContinueCase

EndIf



$kalan = StringStripWS(GUICtrlRead($aInput5), 3)

If $kalan = "" Then

MsgBox(48, "Hata!", "Lütfen Kalan Ücret Ekleyin", 0, $Form2)

GUICtrlSetState($kalan, 256)

ContinueCase

EndIf



$dataModified = StringStripWS(GUICtrlRead($aInput6), 3)



; -------------------------------

If $AType = "Add" Then

For $i = 1 To $BLUE_ARRAY[0][0]

If $BLUE_ARRAY[$i][1] = $productCode Then

GUICtrlSetState($aInput1, 256)

MsgBox(0, "Hata", "Bu Müşteri Var zaten")

ContinueCase

EndIf

Next

$BLUE_ARRAY[0][0] += 1

ReDim $BLUE_ARRAY[$BLUE_ARRAY[0][0] + 1][7]

$BLUE_ARRAY[0][1] = $BLUE_ARRAY[0][0]

EndIf



$BLUE_ARRAY[$BLUE_ARRAY[0][1]][1] = $productCode

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][2] = $make

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][3] = $model

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][4] = $currentStock

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][5] = $kalan

$BLUE_ARRAY[$BLUE_ARRAY[0][1]][6] = $dataModified



IniWrite($INI_FILE, "Musteri_" & $productCode, "Müşteri Adı", $productCode)

IniWrite($INI_FILE, "Musteri_" & $productCode, "Albüm Çeşidi", $make)

IniWrite($INI_FILE, "Musteri_" & $productCode, "Toplam Ücret", $model)

IniWrite($INI_FILE, "Musteri_" & $productCode, "Alınan Ücret", $currentStock)

IniWrite($INI_FILE, "Musteri_" & $productCode, "Kalan Ücret", $kalan)

IniWrite($INI_FILE, "Musteri_" & $productCode, "Tarih", $dataModified)

ExitLoop

EndSwitch

WEnd

_Update_ListView()

GUISwitch($MainForm)

GUISetState(@SW_ENABLE, $MainForm)

GUIDelete($Form2)

EndFunc ;==>_Add_Edit_AProduct



Func _DeleteItem()

Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR

If $GuiRead <> 0 Then

For $i = 1 To $BLUE_ARRAY[0][0]

If $GuiRead = $BLUE_ARRAY[$i][0] Then

GUICtrlDelete($BLUE_ARRAY[$i][0])

IniDelete("musteri.ini", "Musteri_" & $BLUE_ARRAY[$i][1])

$BLUE_ARRAY[$i][0] = -1

ExitLoop

EndIf

Next

EndIf

EndFunc ;==>_DeleteItem



[/spoiler]

Edited by MostWanted
yazım hatası
Link to comment
Share on other sites

Çünkü _DeleteItem fonksiyonundaki IniDelete fonksiyonu "müsteri.ini" yi silmeye çalışıyor senin inin ise $INI_FILE değişkeninde.

 

IniDelete("müsteri.ini", "Musteri_" & $BLUE_ARRAY[$i][1])

 

yerine

 

IniDelete($INI_FILE, "Musteri_" & $BLUE_ARRAY[$i][1]) 

 

yazarsan sorunun çözülür.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...