Jump to content

IF else problem


 Share

Recommended Posts

Dear Guru,

please help. I have made a form for send a ticket to an email. for testing I made that after filling the forms it gives the dialog message. 

But I me the problem that, the script send ro wrong information or dont send at all. 

The description of the form is: 

 - first you have to enter the name,

 - then you have to fill the operator code

- After have to select the manager

- After select the department

- After select the plant 

and here, I met the problem. I have to select the problem from drop down menu, If I dont select, it gives the error. if I select the last point of menu named "Other Problem" it should ask me to fill the Description. But the problem is that it asks me to fill the description even if I choose the existing problem. 

 

So the task is all the form required. 

If some of the from is empty, the form shoud give eror

if in Problem menu there is point "other problem" it shoud ask me to fill the description of the problem,

if   in Problem menu there is any other point , it shoud send the form

 

Please, help me.

here is my code, with my problem 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <Inet.au3>
#include <FontConstants.au3>
#Include <EditConstants.au3>
#Include<file.au3>

#Region ### START Koda GUI section ### Form=
    Local Const $sFont = "Comic Sans Ms"
;~ Create a popup window ----------------------------------------------------------------------------------------------------------------------------
    $Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU,$WS_POPUP,$DS_MODALFRAME), BitOR($WS_EX_TOPMOST,$WS_EX_TRANSPARENT))
    ;~ $Form = GUICreate(" Ticket System ", 320, 600)
    GUISetBkColor(0xFFFFFF)
;~ Create a picture of LOGO ----------------------------------------------------------------------------------------------------------------------------
;~ create header of form ----------------------------------------------------------------------------------------------------------------------------
    Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80)
    GUICtrlSetColor($header, 0x013b84)
    GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
;~ Create input of username ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("User Name", 10, 185, 100, 20)
    Global $idFile = GUICtrlCreateInput("", 100, 185, 200,20)
;~ Create input of user code ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20)
    Global $operatorNumber = GUICtrlCreateInput("", 100, 215,200,20)
;~ Create input of Manager drop down menu ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Select Manager", 10, 245, 100, 20)
    Global $dropManager = GUICtrlCreateCombo("", 100, 245, 200, 20)
    GUICtrlSetData($dropManager, "Manager1|Manager2|Manager3|Manager4|Manager5|Manager6|Manager7|Manager8|", "")
;~ Create input of Department drop down menu ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Select Department", 10, 275, 100, 20)
    Global $dropDepartment = GUICtrlCreateCombo("", 100, 275, 200, 20)
    GUICtrlSetData($dropDepartment, "Production|Planing|Engineering|Materiales|Logistics|IT|Accounting|APM/APT|Quality|Security|Preparation|Maintenance|Purchasing|Health &Safety|HR|Training|QA Supplier|FAE PS ", "")
;~ Create input of Plants drop down menu ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20)
    Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20)
    GUICtrlSetData($dropPlants, "Plant1 |Plant2", "")
;~ Create input of Problems drop down ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Select Problem", 10,335,100,20)
    Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20)
    GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "")
;~ Create input of describing the problem ----------------------------------------------------------------------------------------------------------------------------
    GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20)
    Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200,150, $ES_MULTILINE)
    Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40)
    GUICtrlSetBkColor($idBtn, 0x00b9ef)
    GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
    $LabelError = GUICtrlCreateLabel("", 35,165, 250, 20)
    GUICtrlSetColor($LabelError, $COLOR_RED)
    GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
    ;~ ------------------------------------------------------------------------------------------------------------------------------------
 
    ;~ ======================================================== Logic  ====================================================================
 
    ;~ ------------------------------------------------------------------------------------------------------------------------------------
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $idBtn
                
                $plant = GUICtrlRead($dropPlants)
                $manager = GUICtrlRead($dropManager)
                $department = GUICtrlRead($dropDepartment)
                $problem = GUICtrlRead($dropProblems)
                $name = GUICtrlRead($idFile)
                $id = GUICtrlRead($operatorNumber)
                $description = GUICtrlRead($otherProblem)
 
                If $name == "" Then
                    GUICtrlSetData($LabelError, "You have to enter your name")
                Else
                    if $id == "" Then
                        GUICtrlSetData($LabelError, "You have to enter your operator code")
                    Else
                        if $manager == "" Then
                            GUICtrlSetData($LabelError, "You have to choose your Manager")
                        Else
                            if $department == "" Then
                                GUICtrlSetData($LabelError, "You have to choose your Department")
                            Else
                                if $problem == "Choose the problem..." Then ; Если строка ровняется "Choose the problem..." то
                                    GUICtrlSetData($LabelError, "You have to choose your Problem") ; Выдем ошибку что надо выбрать проблему
                                Else ; Иначе
                                    if $problem == "Other problem" Or $description == "" Then ; Если строка ровняется "Other problem" И описание равняется пустой строке то
                                            GUICtrlSetData($LabelError, "You have to discribe your Problem") ; Выдем ошибку что надо описать проблему
                                        Else ; иначе
                                                ; выдает окнос с формой тикета!
                                            $problem = $description
                                            GUISetState(@SW_HIDE)
                                            MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _ 
                                                    "       [Full Name]: " & $name & @CRLF & _
                                                    "       [FAE-SAU employee's number]: " & $id & @CRLF & _
                                                    "       [Department]: " & $department & @CRLF & _
                                                    "       [Plant location]:Moldova " & $plant & @CRLF & _
                                                    "       [Your Manager's name]: "& $manager & @CRLF & _
                                                    "       [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _
                                                    "Thanks." & @CRLF & @CRLF & _
                                                    "Best Regards," & @CRLF & _
                                                    $name)
                                            Exit
                                    EndIf
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf  
        EndSwitch
    WEnd

Thank you in advance. 

Best regards!

 

P.S. sorry, may be my english is not so good. 

Edited by Melba23
Added code tags
Link to comment
Share on other sites

  • Moderators

Orlina,

Welcome to the AutoIt forums.

When you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation.

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

Here how to streamline your if statements :

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <Inet.au3>
#include <FontConstants.au3>
#include <EditConstants.au3>
#include <file.au3>

Local Const $sFont = "Comic Sans Ms"
;~ Create a popup window ----------------------------------------------------------------------------------------------------------------------------
$Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST)
;~ $Form = GUICreate(" Ticket System ", 320, 600)
GUISetBkColor(0xFFFFFF)
;~ Create a picture of LOGO ----------------------------------------------------------------------------------------------------------------------------
;~ create header of form ----------------------------------------------------------------------------------------------------------------------------
Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80)
GUICtrlSetColor($header, 0x013b84)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
;~ Create input of username ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("User Name", 10, 185, 100, 20)
Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20)
;~ Create input of user code ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20)
Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20)
;~ Create input of Manager drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Manager", 10, 245, 100, 20)
Global $dropManager = GUICtrlCreateCombo("", 100, 245, 200, 20)
GUICtrlSetData($dropManager, "Manager1|Manager2|Manager3|Manager4|Manager5|Manager6|Manager7|Manager8|", "")
;~ Create input of Department drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Department", 10, 275, 100, 20)
Global $dropDepartment = GUICtrlCreateCombo("", 100, 275, 200, 20)
GUICtrlSetData($dropDepartment, "Production|Planing|Engineering|Materiales|Logistics|IT|Accounting|APM/APT|Quality|Security|Preparation|Maintenance|Purchasing|Health &Safety|HR|Training|QA Supplier|FAE PS ", "")
;~ Create input of Plants drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20)
Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20)
GUICtrlSetData($dropPlants, "Plant1 |Plant2", "")
;~ Create input of Problems drop down ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20)
Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20)
GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "")
;~ Create input of describing the problem ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20)
Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE)
Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40)
GUICtrlSetBkColor($idBtn, 0x00b9ef)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
$LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20)
GUICtrlSetColor($LabelError, $COLOR_RED)
GUISetState(@SW_SHOW)

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $idBtn

      $plant = GUICtrlRead($dropPlants)
      $manager = GUICtrlRead($dropManager)
      $department = GUICtrlRead($dropDepartment)
      $problem = GUICtrlRead($dropProblems)
      $name = GUICtrlRead($idFile)
      $id = GUICtrlRead($operatorNumber)
      $description = GUICtrlRead($otherProblem)

      If $name = "" Then
        GUICtrlSetData($LabelError, "You have to enter your name")
      ElseIf $id = "" Then
        GUICtrlSetData($LabelError, "You have to enter your operator code")
      ElseIf $manager = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Manager")
      ElseIf $department = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Department")
      ElseIf $problem = "Choose the problem..." Then
        GUICtrlSetData($LabelError, "You have to choose your Problem")
      ElseIf $problem = "Other problem" And $description = "" Then
        GUICtrlSetData($LabelError, "You have to discribe your Problem")
      Else
        $problem = $description
        GUISetState(@SW_HIDE)
        MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _
            "       [Full Name]: " & $name & @CRLF & _
            "       [FAE-SAU employee's number]: " & $id & @CRLF & _
            "       [Department]: " & $department & @CRLF & _
            "       [Plant location]:Moldova " & $plant & @CRLF & _
            "       [Your Manager's name]: " & $manager & @CRLF & _
            "       [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _
            "Thanks." & @CRLF & @CRLF & _
            "Best Regards," & @CRLF & _
            $name)
        Exit
      EndIf
  EndSwitch
WEnd

 

Edited by Nine
Link to comment
Share on other sites

Dear Nine,

 

Thanks for your reply. 

But, I did so. and any way I met the problem that in form there is no problem from the list. I attached the image (reply.jpg) It seams that the code make 

$problem = $description

but as $description is empty, the problem remains empty. May be this is the reason why there is no problem from the drop menu list.

 

Thank you in davance.

Regards!

Form1.JPG

reply.JPG

Link to comment
Share on other sites

I see. Try this if statement :

If $name = "" Then
        GUICtrlSetData($LabelError, "You have to enter your name")
      ElseIf $id = "" Then
        GUICtrlSetData($LabelError, "You have to enter your operator code")
      ElseIf $manager = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Manager")
      ElseIf $department = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Department")
      ElseIf $problem = "Choose the problem..." Then
        GUICtrlSetData($LabelError, "You have to choose your Problem")
      ElseIf $problem = "Other problem" And $description = "" Then
          GUICtrlSetData($LabelError, "You have to describe your Problem")
      Else
        If $problem = "Other problem" Then $problem = $description
        GUISetState(@SW_HIDE)
        MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _
            "       [Full Name]: " & $name & @CRLF & _
            "       [FAE-SAU employee's number]: " & $id & @CRLF & _
            "       [Department]: " & $department & @CRLF & _
            "       [Plant location]:Moldova " & $plant & @CRLF & _
            "       [Your Manager's name]: " & $manager & @CRLF & _
            "       [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _
            "Thanks." & @CRLF & @CRLF & _
            "Best Regards," & @CRLF & _
            $name)
        Exit
      EndIf

 

Edited by Nine
Link to comment
Share on other sites

Glad you like it.  But here a better version where the edit box gets only available when "other problem" is selected :

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <Inet.au3>
#include <FontConstants.au3>
#include <EditConstants.au3>
#include <file.au3>

Local Const $sFont = "Comic Sans Ms"
;~ Create a popup window ----------------------------------------------------------------------------------------------------------------------------
$Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST)
;~ $Form = GUICreate(" Ticket System ", 320, 600)
GUISetBkColor(0xFFFFFF)
;~ Create a picture of LOGO ----------------------------------------------------------------------------------------------------------------------------
;~ create header of form ----------------------------------------------------------------------------------------------------------------------------
Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80)
GUICtrlSetColor($header, 0x013b84)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
;~ Create input of username ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("User Name", 10, 185, 100, 20)
Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20)
;~ Create input of user code ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20)
Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20)
;~ Create input of Manager drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Manager", 10, 245, 100, 20)
Global $dropManager = GUICtrlCreateCombo("", 100, 245, 200, 20)
GUICtrlSetData($dropManager, "Manager1|Manager2|Manager3|Manager4|Manager5|Manager6|Manager7|Manager8|", "")
;~ Create input of Department drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Department", 10, 275, 100, 20)
Global $dropDepartment = GUICtrlCreateCombo("", 100, 275, 200, 20)
GUICtrlSetData($dropDepartment, "Production|Planing|Engineering|Materiales|Logistics|IT|Accounting|APM/APT|Quality|Security|Preparation|Maintenance|Purchasing|Health &Safety|HR|Training|QA Supplier|FAE PS ", "")
;~ Create input of Plants drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20)
Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20)
GUICtrlSetData($dropPlants, "Plant1 |Plant2", "")
;~ Create input of Problems drop down ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20)
Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20)
GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "")
;~ Create input of describing the problem ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20)
Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE)
GUICtrlSetState(-1, $GUI_DISABLE)
Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40)
GUICtrlSetBkColor($idBtn, 0x00b9ef)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
$LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20)
GUICtrlSetColor($LabelError, $COLOR_RED)
GUISetState(@SW_SHOW)

Local $plant, $manager, $department, $problem, $name, $id, $description

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $dropProblems
      $problem = GUICtrlRead($dropProblems)
      If $problem = "Other problem" Then
        GUICtrlSetState($otherProblem, $GUI_ENABLE)
      Else
        GUICtrlSetState($otherProblem, $GUI_DISABLE)
        GUICtrlSetData($otherProblem, "")
      EndIf
    Case $idBtn
      $plant = GUICtrlRead($dropPlants)
      $manager = GUICtrlRead($dropManager)
      $department = GUICtrlRead($dropDepartment)
      $problem = GUICtrlRead($dropProblems)
      $name = GUICtrlRead($idFile)
      $id = GUICtrlRead($operatorNumber)
      $description = GUICtrlRead($otherProblem)

      If $name = "" Then
        GUICtrlSetData($LabelError, "You have to enter your name")
      ElseIf $id = "" Then
        GUICtrlSetData($LabelError, "You have to enter your operator code")
      ElseIf $manager = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Manager")
      ElseIf $department = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Department")
      ElseIf $problem = "Choose the problem..." Then
        GUICtrlSetData($LabelError, "You have to choose your Problem")
      ElseIf $problem = "Other problem" And $description = "" Then
          GUICtrlSetData($LabelError, "You have to describe your Problem")
      Else
        If $problem = "Other problem" Then $problem = $description
        GUISetState(@SW_HIDE)
        MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _
            "       [Full Name]: " & $name & @CRLF & _
            "       [FAE-SAU employee's number]: " & $id & @CRLF & _
            "       [Department]: " & $department & @CRLF & _
            "       [Plant location]:Moldova " & $plant & @CRLF & _
            "       [Your Manager's name]: " & $manager & @CRLF & _
            "       [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _
            "Thanks." & @CRLF & @CRLF & _
            "Best Regards," & @CRLF & _
            $name)
        Exit
      EndIf
  EndSwitch
WEnd

 

Link to comment
Share on other sites

Dear Nine,

 

I knew it that there was a simple solution XD but it seams that I have not enough brains.... XDDD

but one nore simple question...

 

I would like also to reduce the number of inputs.  I mean that I want to choose only department, but manager of department should be choosen by selected department. 

 

I know that it should be realised by if else... but I have the small experiense in developming and have no idea where I should do thhis checking. 

I hope you at least give me advice how to do it ))

Thank you in advance. 

Link to comment
Share on other sites

Hmmm.  Do not take an habit to ask for help without making first an effort.  I will give you a hand this time because you are new here and also because I am sometimes nice.

BTW  If you want to start having multiple relations between entities, you should think using a RDBMS like SQLite, instead (like I did) making it hard coded.  Anyway there you go, and please next time, provide your code attempt even if it is not working at all.

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
#include <ColorConstants.au3>
#include <ComboConstants.au3>
#include <ButtonConstants.au3>
#include <Inet.au3>
#include <FontConstants.au3>
#include <EditConstants.au3>
#include <file.au3>

Local $aManager [] = ["Manager1","Manager2","Manager3","Manager4","Manager5","Manager6","Manager7","Manager8","Manager9","ManagerA","ManagerB","ManagerC","ManagerD","ManagerE","ManagerF","ManagerG","ManagerH","ManagerI"]
Local $aDepartment [] = ["Production","Planing","Engineering","Materiales","Logistics","IT","Accounting","APM/APT","Quality","Security","Preparation","Maintenance","Purchasing","Health &Safety","HR","Training","QA Supplier","FAE PS"]

If UBound($aDepartment) <> UBound($aManager) Then Exit MsgBox ($MB_SYSTEMMODAL, "Error", "Number of Managers should be same of Departments")

Local Const $sFont = "Comic Sans Ms"
;~ Create a popup window ----------------------------------------------------------------------------------------------------------------------------
$Form = GUICreate(" Ticket System ", 320, 600, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $DS_MODALFRAME), $WS_EX_TOPMOST)
;~ $Form = GUICreate(" Ticket System ", 320, 600)
GUISetBkColor(0xFFFFFF)
;~ Create a picture of LOGO ----------------------------------------------------------------------------------------------------------------------------
;~ create header of form ----------------------------------------------------------------------------------------------------------------------------
Global $header = GUICtrlCreateLabel("Ticket Form", 90, 110, 165, 80)
GUICtrlSetColor($header, 0x013b84)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
;~ Create input of username ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("User Name", 10, 185, 100, 20)
Global $idFile = GUICtrlCreateInput("", 100, 185, 200, 20)
;~ Create input of user code ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Operator Number", 10, 215, 100, 20)
Global $operatorNumber = GUICtrlCreateInput("", 100, 215, 200, 20)

;~ Create input of Department drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Department", 10, 245, 100, 20)
Global $dropDepartment = GUICtrlCreateCombo("", 100, 245, 200, 20)
GUICtrlSetData($dropDepartment,_ArrayToString($aDepartment))
GUICtrlCreateLabel("Manager", 10, 275, 100, 20)
Global $idManager = GUICtrlCreateLabel("", 100, 275, 200, 20, $SS_SUNKEN)

;~ Create input of Plants drop down menu ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Plant", 10, 305, 100, 20)
Global $dropPlants = GUICtrlCreateCombo("", 100, 305, 200, 20)
GUICtrlSetData($dropPlants, "Plant1 |Plant2", "")
;~ Create input of Problems drop down ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Select Problem", 10, 335, 100, 20)
Global $dropProblems = GUICtrlCreateCombo("Choose the problem...", 100, 335, 200, 20)
GUICtrlSetData($dropProblems, "No Network|Need Skype account|Need access|Printing limit finished|Freezed form|Outlook Doen't work|Change Keyboard|Change Mouse|Change Monitor|Install Software|Don't work Printer|Doesn't Work Macros|Other problem", "")
;~ Create input of describing the problem ----------------------------------------------------------------------------------------------------------------------------
GUICtrlCreateLabel("Other Problem", 10, 440, 100, 20)
Global $otherProblem = GUICtrlCreateEdit("", 100, 365, 200, 150, $ES_MULTILINE)
GUICtrlSetState(-1, $GUI_DISABLE)
Local $idBtn = GUICtrlCreateButton("OK", 60, 530, 200, 40)
GUICtrlSetBkColor($idBtn, 0x00b9ef)
GUICtrlSetFont(-1, 20, $FW_EXTRABOLD)
$LabelError = GUICtrlCreateLabel("", 35, 165, 250, 20)
GUICtrlSetColor($LabelError, $COLOR_RED)
GUISetState(@SW_SHOW)

Local $plant, $manager, $department, $problem, $name, $id, $description

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $dropDepartment
      $id = _ArraySearch($aDepartment, GUICtrlRead($dropDepartment))
      GUICtrlSetData($idManager, $aManager[$id])
    Case $dropProblems
      $problem = GUICtrlRead($dropProblems)
      If $problem = "Other problem" Then
        GUICtrlSetState($otherProblem, $GUI_ENABLE)
      Else
        GUICtrlSetState($otherProblem, $GUI_DISABLE)
        GUICtrlSetData($otherProblem, "")
      EndIf
    Case $idBtn
      $plant = GUICtrlRead($dropPlants)
      $manager = GUICtrlRead($idManager)
      $department = GUICtrlRead($dropDepartment)
      $problem = GUICtrlRead($dropProblems)
      $name = GUICtrlRead($idFile)
      $id = GUICtrlRead($operatorNumber)
      $description = GUICtrlRead($otherProblem)

      If $name = "" Then
        GUICtrlSetData($LabelError, "You have to enter your name")
      ElseIf $id = "" Then
        GUICtrlSetData($LabelError, "You have to enter your operator code")
      ElseIf $department = "" Then
        GUICtrlSetData($LabelError, "You have to choose your Department")
      ElseIf $problem = "Choose the problem..." Then
        GUICtrlSetData($LabelError, "You have to choose your Problem")
      ElseIf $problem = "Other problem" And $description = "" Then
          GUICtrlSetData($LabelError, "You have to describe your Problem")
      Else
        If $problem = "Other problem" Then $problem = $description
        GUISetState(@SW_HIDE)
        MsgBox($MB_OK, "OK", "Hello," & @CRLF & @CRLF & _
            "       [Full Name]: " & $name & @CRLF & _
            "       [FAE-SAU employee's number]: " & $id & @CRLF & _
            "       [Department]: " & $department & @CRLF & _
            "       [Plant location]:Moldova " & $plant & @CRLF & _
            "       [Your Manager's name]: " & $manager & @CRLF & _
            "       [Explain your problem]: Please, we have a problem: " & $problem & "." & @CRLF & @CRLF & _
            "Thanks." & @CRLF & @CRLF & _
            "Best Regards," & @CRLF & _
            $name)
        Exit
      EndIf
  EndSwitch
WEnd

 

Link to comment
Share on other sites

Thank you Dear Nine. 

 

I will keep in ming your comment. 

honestly I prefer JavaScript and know this language more better than AutoIT. But as I was requested to do this form I had to meet with AutoIt.

please forgive me for my irregularities and disrespect.

 

Thank you very veru much once again.

Have a nice day. 

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...