Guest User

Untitled

a guest
Jul 31st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.64 KB | None | 0 0
  1. Func _del_product_button($hParent = 0)
  2. Local  $iGOEM_Opt
  3. $iGOEM_Opt = Opt("GUIOnEventMode", 0)
  4.     $Form_del_product = GUICreate("Удалить продукт", 475, 37, -1, -1)
  5.     $Tovar_Combo_del = GUICtrlCreateCombo("Выберите удаляемый продукт", 8, 8, 393, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
  6.     $del_product= GUICtrlCreateButton("Дальше", 408, 8, 51, 22)
  7.     my_FillCombo($Tovar_Combo_del,$edit_tovar_arr)
  8.     ;заполняем combo из add_product_button
  9.     ;GUISetState(@SW_DISABLE, $hParent)
  10.     GUISetState(@SW_SHOW, $Form_del_product)
  11.     ;MsgBox(0,'',GUICtrlRead($Tovar_Combo_del))
  12.         While 1
  13.             $nMsg = GUIGetMsg()
  14.             Switch $nMsg
  15.                 Case $GUI_EVENT_CLOSE
  16.                     ;GUISetState(@SW_ENABLE, $hMain_GUI)
  17.                     GUIDelete($Form_del_product)
  18.                     ExitLoop
  19.                     ;Send('{ESC}')
  20.                 Case $Tovar_Combo_del
  21.                     $id_tovar=my_GetId($Tovar_Combo_del)
  22.                     ;MsgBox(0,'',$edit_tovar_arr[$id_tovar][0]); id выбираемого товара в базе
  23.                 case $del_product
  24.                 ;_ArrayDisplay($edit_tovar_arr); Выбрать товар для редактирования
  25.  
  26.                     if GUICtrlRead($Tovar_Combo_del) == "Выберите удаляемый продукт" Then
  27.                         MsgBox(64,'Ошибка','Вы не выбрали раздел')
  28.                     ContinueLoop
  29.                     EndIf
  30.                     $query = "DELETE FROM `shop_product` WHERE id = '"& $edit_tovar_arr[$id_tovar][0] &"' "
  31.                     $mysql_bool = _MySQL_Real_Query($MysqlConn, $query)
  32.                     If $mysql_bool = $MYSQL_SUCCESS Then
  33.                         TrayTip("","Запрос обработан",2000)
  34.                     Else
  35.                         $errno = _MySQL_errno($MysqlConn)
  36.                         MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn))
  37.                     EndIf
  38.                     $res = _MySQL_Store_Result($MysqlConn)
  39.                     $arr_edit_product = _MySQL_Fetch_Result_StringArray($res)
  40.                     ;_ArrayDisplay($arr_edit_product); Выборка продукта с заданным id
  41.                     GUIDelete($Form_del_product)
  42.                     ; Обновляем список продуктов после добавления товара
  43.                     $query = "SELECT `id`,`name` FROM `shop_product`"
  44.                     $mysql_bool = _MySQL_Real_Query($MysqlConn, $query)
  45.                     If $mysql_bool = $MYSQL_SUCCESS Then
  46.                         ;MsgBox(0, '', "Query OK"); Удачный запрос или нет
  47.                     Else
  48.                         $errno = _MySQL_errno($MysqlConn)
  49.                         MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn))
  50.                     EndIf
  51.                     $res = _MySQL_Store_Result($MysqlConn)
  52.                     $edit_tovar_arr = _MySQL_Fetch_Result_StringArray($res)
  53.                     _del_product_button($hMain_GUI)
  54.  
  55.             EndSwitch
  56.  
  57.         WEnd
  58.     Opt("GUIOnEventMode", $iGOEM_Opt)
  59.     GUISetState(@SW_ENABLE, $hParent)
  60.     GUIDelete($Form_del_product)
  61.  
  62. EndFunc
Add Comment
Please, Sign In to add comment