bmozdemir Posted March 23, 2012 Share Posted March 23, 2012 (edited) Benim aşağıda vermiş olduğum açıkcası bu sitede gördüğüm kod üzerine bir sorum olacaktı. Sil butonunun list wiev ekranından seçilerek silinmesini yani sil butonuna bastığımızda açılan menüden item seçilerek değilde listeden line seçilerek silinmesini istiyorum acaba bunu nasıl yapabilirim. Eğer ilgilenirseniz sevinirim iyi günler. [codebox] #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <array.au3> #include <ComboConstants.au3> Global $productCode, $make, $model, $currentStock, $dataModified, $productToEdit $Form1 = GUICreate("Form1", 623, 442, 192, 124) $ListView1 = GUICtrlCreateDummy() $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25) $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25) $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25) GUISetState(@SW_SHOW) _RefreshData() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _AddAProduct() Case $Button2 _EditProduct() Case $Button3 _DeleteItem() EndSwitch WEnd Func _AddAProduct() $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218) $aInput1 = GUICtrlCreateInput("", 16, 24, 193, 21) $aInput2 = GUICtrlCreateInput("", 16, 64, 193, 21) $aInput3 = GUICtrlCreateInput("", 16, 104, 193, 21) $aInput4 = GUICtrlCreateInput("", 16, 144, 193, 21) $aInput5 = GUICtrlCreateInput(@MON & "/" & @MDAY & "/" & @YEAR, 16, 184, 193, 21) $Label1 = GUICtrlCreateLabel("Product Code", 224, 24, 69, 17) $Label2 = GUICtrlCreateLabel("Make", 224, 64, 31, 17) $Label3 = GUICtrlCreateLabel("Model", 224, 104, 33, 17) $Label4 = GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17) $Label5 = GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17) $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) ExitLoop Case $cButton3 $productCode = GUICtrlRead($aInput1) $make = GUICtrlRead($aInput2) $model = GUICtrlRead($aInput3) $currentStock = GUICtrlRead($aInput4) $dataModified = GUICtrlRead($aInput5) $errorCheck = IniRead("InventoryData.ini", $productCode, "Product Code", "NotInDatabase") If $errorCheck = "NotInDatabase" Then IniWrite("InventoryData.ini", $productCode, "Product Code", $productCode) IniWrite("InventoryData.ini", $productCode, "Make", $make) IniWrite("InventoryData.ini", $productCode, "Model", $model) IniWrite("InventoryData.ini", $productCode, "Current Stock", $currentStock) IniWrite("InventoryData.ini", $productCode, "Date Modified", $dataModified) Else MsgBox(0, "Error", "The product is already in the database") EndIf GUIDelete($Form2) _RefreshData() ExitLoop EndSwitch WEnd EndFunc ;==>_AddAProduct Func _RefreshData() GUISwitch($Form1) GUICtrlDelete($ListView1) $ListView1 = GUICtrlCreateListView("Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 85) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 100) $sectionNames = IniReadSectionNames("InventoryData.ini") If @error Then Dim $sectionNames[2] $sectionNames[0] = 1 $sectionNames[1] = "NotFound" EndIf _ArraySort($sectionNames, 0, 1) For $i = 1 To $sectionNames[0] Step 1 $productCode = IniRead("InventoryData.ini", $sectionNames[$i], "Product Code", "") $make = IniRead("InventoryData.ini", $sectionNames[$i], "Make", "") $model = IniRead("InventoryData.ini", $sectionNames[$i], "Model", "") $currentStock = IniRead("InventoryData.ini", $sectionNames[$i], "Current Stock", "") $dataModified = IniRead("InventoryData.ini", $sectionNames[$i], "Date Modified", "") GUICtrlCreateListViewItem($productCode & "|" & $make & "|" & $model & "|" & $currentStock & "|" & $dataModified, $ListView1) If Number($currentStock) < 100 Then GUICtrlSetBkColor(-1, 0xfff333) EndIf If Number($currentStock) < 10 Then GUICtrlSetBkColor(-1, 0xff0000) EndIf Next EndFunc ;==>_RefreshData Func _DeleteItem() $Form3 = GUICreate("Delete A Product", 303, 169, 302, 218) $sectionNames = IniReadSectionNames("InventoryData.ini") If @error Then ;MsgBox(0, "", "Error") Dim $sectionNames[2] $sectionNames[0] = 1 $sectionNames[1] = "NotFound" EndIf _ArraySort($sectionNames, 0, 1) $delCombo = GUICtrlCreateCombo("", 24, 40, 241, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) $delLabel1 = GUICtrlCreateLabel("Select an item to delete", 24, 16, 115, 17) $delLabel2 = GUICtrlCreateLabel("Warning: this cannot be undone", 24, 72, 186, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $delButton1 = GUICtrlCreateButton("Delete Item", 168, 112, 91, 25) GUISetState(@SW_SHOW) For $i = 1 To $sectionNames[0] Step 1 GUICtrlSetData($delCombo, $sectionNames[$i]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form3) ExitLoop Case $delButton1 $delete = GUICtrlRead($delCombo) IniDelete("InventoryData.ini", $delete) GUIDelete($Form3) _RefreshData() ExitLoop EndSwitch WEnd EndFunc ;==>_DeleteItem Func _EditProduct() $sectionNames = IniReadSectionNames("InventoryData.ini") If @error Then Dim $sectionNames[2] $sectionNames[0] = 1 $sectionNames[1] = "NotFound" EndIf _ArraySort($sectionNames, 0, 1) $Form4 = GUICreate("Edit a product", 303, 169, 302, 218) $delCombo = GUICtrlCreateCombo("", 24, 40, 241, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) $delLabel1 = GUICtrlCreateLabel("Select an item to edit", 24, 16, 115, 17) $delButton1 = GUICtrlCreateButton("Edit Item", 168, 112, 91, 25) GUISetState(@SW_SHOW) For $i = 1 To $sectionNames[0] Step 1 GUICtrlSetData($delCombo, $sectionNames[$i]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form4) ExitLoop Case $delButton1 $productToEdit = GUICtrlRead($delCombo) If $productToEdit = "" Then GUIDelete($Form4) ExitLoop Else GUIDelete($Form4) _EditProductForm() ExitLoop EndIf EndSwitch WEnd EndFunc ;==>_EditProduct Func _EditProductForm() $make = IniRead("InventoryData.ini", $productToEdit, "Make", "") $model = IniRead("InventoryData.ini", $productToEdit, "Model", "") $currentStock = IniRead("InventoryData.ini", $productToEdit, "Current Stock", "") $dataModified = IniRead("InventoryData.ini", $productToEdit, "Date Modified", "") $Form5 = GUICreate("Form1", 336, 258, 302, 218) $cInput1 = GUICtrlCreateInput($productToEdit, 16, 24, 193, 21) $cInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21) $cInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21) $cInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21) $cInput5 = GUICtrlCreateInput(@MON & "/" & @MDAY & "/" & @YEAR, 16, 184, 193, 21) $Label1 = GUICtrlCreateLabel("Product Code", 224, 24, 69, 17) $Label2 = GUICtrlCreateLabel("Make", 224, 64, 31, 17) $Label3 = GUICtrlCreateLabel("Model", 224, 104, 33, 17) $Label4 = GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17) $Label5 = GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17) $Button3 = GUICtrlCreateButton("Edit Product", 120, 216, 91, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form5) ExitLoop Case $Button3 $productCode = GUICtrlRead($cInput1) $make = GUICtrlRead($cInput2) $model = GUICtrlRead($cInput3) $currentStock = GUICtrlRead($cInput4) $dataModified = GUICtrlRead($cInput5) IniWrite("InventoryData.ini", $productCode, "Product Code", $productCode) IniWrite("InventoryData.ini", $productCode, "Make", $make) IniWrite("InventoryData.ini", $productCode, "Model", $model) IniWrite("InventoryData.ini", $productCode, "Current Stock", $currentStock) IniWrite("InventoryData.ini", $productCode, "Date Modified", $dataModified) GUIDelete($Form5) _RefreshData() ExitLoop EndSwitch WEnd EndFunc ;==>_EditProductForm [/codebox] Edited March 27, 2012 by bmozdemir Quote Link to comment Share on other sites More sharing options...
blue_life Posted March 23, 2012 Share Posted March 23, 2012 @bmozdemir Kısaca; [codebox]#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <array.au3> #include <ComboConstants.au3> Global $productCode, $make, $model, $currentStock, $dataModified, $productToEdit $Form1 = GUICreate("Form1", 623, 442, 192, 124) $ListView1 = GUICtrlCreateDummy() $Button1 = GUICtrlCreateButton("Add A Product", 16, 408, 91, 25) $Button2 = GUICtrlCreateButton("Edit A Product", 120, 408, 91, 25) $Button3 = GUICtrlCreateButton("Delete A Product", 224, 408, 107, 25) GUISetState(@SW_SHOW) _RefreshData() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _AddAProduct() Case $Button2 _EditProduct() Case $Button3 _DeleteItem() EndSwitch WEnd Func _AddAProduct() $Form2 = GUICreate("Product Inventory", 336, 258, 302, 218) $aInput1 = GUICtrlCreateInput("", 16, 24, 193, 21) $aInput2 = GUICtrlCreateInput("", 16, 64, 193, 21) $aInput3 = GUICtrlCreateInput("", 16, 104, 193, 21) $aInput4 = GUICtrlCreateInput("", 16, 144, 193, 21) $aInput5 = GUICtrlCreateInput(@MON & "/" & @MDAY & "/" & @YEAR, 16, 184, 193, 21) $Label1 = GUICtrlCreateLabel("Product Code", 224, 24, 69, 17) $Label2 = GUICtrlCreateLabel("Make", 224, 64, 31, 17) $Label3 = GUICtrlCreateLabel("Model", 224, 104, 33, 17) $Label4 = GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17) $Label5 = GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17) $cButton3 = GUICtrlCreateButton("Add Product", 120, 216, 91, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) ExitLoop Case $cButton3 $productCode = GUICtrlRead($aInput1) $make = GUICtrlRead($aInput2) $model = GUICtrlRead($aInput3) $currentStock = GUICtrlRead($aInput4) $dataModified = GUICtrlRead($aInput5) $errorCheck = IniRead("InventoryData.ini", $productCode, "Product Code", "NotInDatabase") If $errorCheck = "NotInDatabase" Then IniWrite("InventoryData.ini", $productCode, "Product Code", $productCode) IniWrite("InventoryData.ini", $productCode, "Make", $make) IniWrite("InventoryData.ini", $productCode, "Model", $model) IniWrite("InventoryData.ini", $productCode, "Current Stock", $currentStock) IniWrite("InventoryData.ini", $productCode, "Date Modified", $dataModified) Else MsgBox(0, "Error", "The product is already in the database") EndIf GUIDelete($Form2) _RefreshData() ExitLoop EndSwitch WEnd EndFunc ;==>_AddAProduct Func _RefreshData() GUISwitch($Form1) GUICtrlDelete($ListView1) $ListView1 = GUICtrlCreateListView("Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 150) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 85) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 100) $sectionNames = IniReadSectionNames("InventoryData.ini") If @error Then Dim $sectionNames[2] $sectionNames[0] = 1 $sectionNames[1] = "NotFound" EndIf _ArraySort($sectionNames, 0, 1) For $i = 1 To $sectionNames[0] Step 1 $productCode = IniRead("InventoryData.ini", $sectionNames[$i], "Product Code", "") $make = IniRead("InventoryData.ini", $sectionNames[$i], "Make", "") $model = IniRead("InventoryData.ini", $sectionNames[$i], "Model", "") $currentStock = IniRead("InventoryData.ini", $sectionNames[$i], "Current Stock", "") $dataModified = IniRead("InventoryData.ini", $sectionNames[$i], "Date Modified", "") GUICtrlCreateListViewItem($productCode & "|" & $make & "|" & $model & "|" & $currentStock & "|" & $dataModified, $ListView1) If Number($currentStock) < 100 Then GUICtrlSetBkColor(-1, 0xfff333) EndIf If Number($currentStock) < 10 Then GUICtrlSetBkColor(-1, 0xff0000) EndIf Next EndFunc ;==>_RefreshData Func _DeleteItem() Local $GuiRead = GUICtrlRead($ListView1), $GuiRead2, $SINSTR If $GuiRead <> 0 Then $GuiRead2 = GUICtrlRead($GuiRead) $SINSTR = StringInStr($GuiRead2, "|") If $SINSTR <> 0 Then $GuiRead2 = StringLeft($GuiRead2, $SINSTR - 1) GUICtrlDelete($GuiRead) IniDelete("InventoryData.ini", $GuiRead2) EndIf EndFunc ;==>_DeleteItem Func _EditProduct() $sectionNames = IniReadSectionNames("InventoryData.ini") If @error Then Dim $sectionNames[2] $sectionNames[0] = 1 $sectionNames[1] = "NotFound" EndIf _ArraySort($sectionNames, 0, 1) $Form4 = GUICreate("Edit a product", 303, 169, 302, 218) $delCombo = GUICtrlCreateCombo("", 24, 40, 241, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) $delLabel1 = GUICtrlCreateLabel("Select an item to edit", 24, 16, 115, 17) $delButton1 = GUICtrlCreateButton("Edit Item", 168, 112, 91, 25) GUISetState(@SW_SHOW) For $i = 1 To $sectionNames[0] Step 1 GUICtrlSetData($delCombo, $sectionNames[$i]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form4) ExitLoop Case $delButton1 $productToEdit = GUICtrlRead($delCombo) If $productToEdit = "" Then GUIDelete($Form4) ExitLoop Else GUIDelete($Form4) _EditProductForm() ExitLoop EndIf EndSwitch WEnd EndFunc ;==>_EditProduct Func _EditProductForm() $make = IniRead("InventoryData.ini", $productToEdit, "Make", "") $model = IniRead("InventoryData.ini", $productToEdit, "Model", "") $currentStock = IniRead("InventoryData.ini", $productToEdit, "Current Stock", "") $dataModified = IniRead("InventoryData.ini", $productToEdit, "Date Modified", "") $Form5 = GUICreate("Form1", 336, 258, 302, 218) $cInput1 = GUICtrlCreateInput($productToEdit, 16, 24, 193, 21) $cInput2 = GUICtrlCreateInput($make, 16, 64, 193, 21) $cInput3 = GUICtrlCreateInput($model, 16, 104, 193, 21) $cInput4 = GUICtrlCreateInput($currentStock, 16, 144, 193, 21) $cInput5 = GUICtrlCreateInput(@MON & "/" & @MDAY & "/" & @YEAR, 16, 184, 193, 21) $Label1 = GUICtrlCreateLabel("Product Code", 224, 24, 69, 17) $Label2 = GUICtrlCreateLabel("Make", 224, 64, 31, 17) $Label3 = GUICtrlCreateLabel("Model", 224, 104, 33, 17) $Label4 = GUICtrlCreateLabel("Current Stock", 224, 144, 69, 17) $Label5 = GUICtrlCreateLabel("Date Modified", 224, 184, 70, 17) $Button3 = GUICtrlCreateButton("Edit Product", 120, 216, 91, 25) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form5) ExitLoop Case $Button3 $productCode = GUICtrlRead($cInput1) $make = GUICtrlRead($cInput2) $model = GUICtrlRead($cInput3) $currentStock = GUICtrlRead($cInput4) $dataModified = GUICtrlRead($cInput5) IniWrite("InventoryData.ini", $productCode, "Product Code", $productCode) IniWrite("InventoryData.ini", $productCode, "Make", $make) IniWrite("InventoryData.ini", $productCode, "Model", $model) IniWrite("InventoryData.ini", $productCode, "Current Stock", $currentStock) IniWrite("InventoryData.ini", $productCode, "Date Modified", $dataModified) GUIDelete($Form5) _RefreshData() ExitLoop EndSwitch WEnd EndFunc ;==>_EditProductForm[/codebox] Quote Link to comment Share on other sites More sharing options...
bmozdemir Posted March 24, 2012 Author Share Posted March 24, 2012 blue_life ilginize alakanıza çok teşekkür ederim. Yalnız bişşi daha sormak istiyorum. Bu edit bölümünüde edit tuşuna basıldığında listview ekranındaki line dan biri seçildiğinde add butonundaki gibi pencere açılıp oraya bilgilerin çağırılmasını nasıl yapabiliriz. İlginize tekrar çok teşekkür ederim. İyi akşamlar. Quote Link to comment Share on other sites More sharing options...
blue_life Posted March 25, 2012 Share Posted March 25, 2012 @bmozdemir Rica ederim. İstediğinle birlikte, örneğinde hatalı kısımları biraz düzelttim... [codebox] ;~ #include <GUIConstantsEx.au3> ;~ #include <ListViewConstants.au3> ;~ #include <WindowsConstants.au3> ;~ #include <ButtonConstants.au3> ;~ #include <StaticConstants.au3> ;~ #include <ComboConstants.au3> #include <array.au3> Global $ScriptDir = @ScriptDir If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\" Global $INI_FILE = $ScriptDir & "InventoryData.ini" Global $BLUE_ARRAY Global $MainForm = GUICreate("Form1", 623, 442) Global $ListView1 = GUICtrlCreateListView("Product Code|Make|Model|Current Stock|Date Modified", 16, 8, 586, 390) GUICtrlSendMsg(-1, 4126, 0, 100) GUICtrlSendMsg(-1, 4126, 1, 150) GUICtrlSendMsg(-1, 4126, 2, 150) GUICtrlSendMsg(-1, 4126, 3, 85) GUICtrlSendMsg(-1, 4126, 4, 100) _Update_ListView() ;Update ListView 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][6] ;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], <> "Product_" 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][6] $RETURN_ARRAY[$RETURN_ARRAY[0][0]][1] = StringStripWS(IniRead($INI_FILE, $RAD_ISName[$i], "Product Code", ""), 3) $RETURN_ARRAY[$RETURN_ARRAY[0][0]][2] = IniRead($INI_FILE, $RAD_ISName[$i], "Make", "") $RETURN_ARRAY[$RETURN_ARRAY[0][0]][3] = IniRead($INI_FILE, $RAD_ISName[$i], "Model", "") $RETURN_ARRAY[$RETURN_ARRAY[0][0]][4] = IniRead($INI_FILE, $RAD_ISName[$i], "Current Stock", "") $RETURN_ARRAY[$RETURN_ARRAY[0][0]][5] = 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][6] 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], $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, $dataModified = @MON & "/" & @MDAY & "/" & @YEAR 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 $productCode = $BLUE_ARRAY[$i][1] $make = $BLUE_ARRAY[$i][2] $model = $BLUE_ARRAY[$i][3] $currentStock = $BLUE_ARRAY[$i][4] $dataModified = $BLUE_ARRAY[$i][5] 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, 0x2000) Local $aInput5 = GUICtrlCreateInput($dataModified, 16, 184, 193, 21) 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 = Number(GUICtrlRead($aInput4)) If $currentStock = 0 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][6] $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] = $dataModified IniWrite($INI_FILE, "Product_" & $productCode, "Product Code", $productCode) IniWrite($INI_FILE, "Product_" & $productCode, "Make", $make) IniWrite($INI_FILE, "Product_" & $productCode, "Model", $model) IniWrite($INI_FILE, "Product_" & $productCode, "Current Stock", $currentStock) IniWrite($INI_FILE, "Product_" & $productCode, "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", "Product_" & $BLUE_ARRAY[$i][1]) $BLUE_ARRAY[$i][0] = -1 ExitLoop EndIf Next EndIf EndFunc ;==>_DeleteItem[/codebox] Quote Link to comment Share on other sites More sharing options...
bmozdemir Posted March 25, 2012 Author Share Posted March 25, 2012 (edited) @blue_life Valla çok teşekkür ederim yardımlarından dolayı evet gerçekten mükemmel olmuş elinize sağlık. [warning][b][color=#FF0000]Forumda açılan konulara teşekkür etmek için teşekkür butonunu kullanınız! [topic=872]Lütfen Forum Kurallarını Okuyunuz.[/topic] Anlayışınız için teşekkür ederiz Tnc-Team[/color][/b][/warning] Edited March 25, 2012 by blue_life Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.