Jump to content
Sign in to follow this  
randeep

input form reappearance

Recommended Posts

randeep

hello all

i have written a script (below, shortened to make understand easily). the very first function in the function "ConDeConSingleSite()" is InputWindowForSingleSite(). now in this function a form opens. which requires some parameters out of which one is database name ($InputOfInputBoxDataBaseName). now the next thing in this scripts is, it check the input provided for database name to the location C:\Data. now i want that if the above entry (provided in input box for database) is present at "C:\Data" then program should come again to the inputwindow and should ask to enter the database name as it already exists. the solution i have written is not appropriate acc. to me because its looking very 'ODD'. pls suggest what should i do. :D

(Pls place the attachment at C:\Data)

thanx

#cs ----------------------------------------------------------------------------

 Function Name: ConDeConSingleSite()
 Author:         Randeep Singh

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------


#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>
#INCLUDE <File.au3>


ConDeConSingleSite()
Func ConDeConSingleSite()

    Local $ConfigureButton, $DeConfigureButton, $SubmitButton
    Local $GUIHandle

    GUICreate("Single Site Configuration", 225, 125)
    GUISetIcon("ARTEVEAI.ICO",-20)
    GUISetState(@SW_SHOW)
    GUICtrlCreateLabel("Please Select to Configure or De-Configure", 10, 30)
    guictrlcreatelabel("Single Site!", 90, 50)
    $ConfigureButton = GUICtrlCreateButton("Configure", 20, 80, 80)
    $DeConfigureButton = GUICtrlCreateButton("De-Configure", 125, 80, 80)

    While 1

            Switch GUIGetMsg()

                Case $GUI_EVENT_CLOSE
                    ;GUIDELETE()
                    ExitLoop

                Case $ConfigureButton
                    GUIDELETE()

                    Local $Pic1, $Pic2, $Pic3, $Pic4, $Pic5
;=========================================================================================================

                        InputWindowForSingleSite()

                    local $x, $y

                    ShellExecute ("C:\Data")
                    WinWaitActive("Data")

                    $x = ControlListView("Data", "", 1, "FindItem", $InputOfInputBoxDataBaseName & "_Log.LDF")

                    if $x <> -1 Then
                        $y = msgbox(4, "", "The Database with the name " & $InputOfInputBoxDataBaseName & " already exist, do you want to delete it")
                    if $y = 7 then
                                InputWindowForSingleSite()
                            EndIf
                    EndIf

                        sleep (30000)

;=========================================================================================================

                    GUIDelete($GUIHandle)
                    GUIDelete($InputWindowHandle)
                    ;ExitLoop
                Case $DeConfigureButton
                    GUIDELETE()

                    ;if SingleSiteDeconfigure() = True Then
                        msgbox(0, "Message", "Congratulations!!! The Single Site is De-Configured now.")
                    ;EndIf
                    GUIDelete();$GUIHandle
                    ;GUIDelete($InputWindowHandle)
                    exitloop

            EndSwitch
    WEnd

    GUIDelete()

EndFunc

#cs ----------------------------------------------------------------------------

 Function Name: InputWindowForSingleSite()
 Author:         Randeep Singh

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

Func InputWindowForSingleSite()

Local $msg1, $Btn_OK, $Label1, $Label2, $Label3, $Label4, $Label5, $Input1, $Input2, $Input3, $Input4, $Input5, $MainLabel, $InputWindowHandle
Local $RetValue = True

Opt("GUIOnEventMode",0)

    $InputWindowHandle = GUICreate("Details for Single Sites", 250, 250, -1, -1, $WS_EX_DLGMODALFRAME)  ; will create a dialog box that when displayed is centered
    GUISetIcon("ARTEVEAI.ICO",-20)
    $MainLabel = GUICtrlCreateLabel("Please provide following details", 10, 20)
    $Label1 = GUICtrlCreateLabel("Database Name", 10, 50)
    $Label2 = GUICtrlCreateLabel("IP Address", 10, 80)
    $Label3 = GUICtrlCreateLabel("HostName", 10, 110)
    $Label4 = GUICtrlCreateLabel("Username", 10, 140)
    $Label5 = GUICtrlCreateLabel("Password", 10, 170)

    $Input1 = GUICtrlCreateInput("", 150, 43, 80)                                   ;for DB Name
    $Input2 = GUICtrlCreateInput("", 150, 73, 80, 0, $ES_NUMBER)                    ;for Ip address
    $Input3 = GUICtrlCreateInput("", 150, 103, 80)
    $Input4 = guictrlcreateinput("", 150, 133, 80)                                  ;for Username
    $Input5 = guictrlcreateinput("", 150, 163, 80)                                  ;for password
    $Btn_OK = GUICtrlCreateButton("OK", 90, 193, 80)                                ;OK button

GuiCtrlSetState($Btn_OK, $GUI_Disable)
GUISetState()
Local $Enabled = False

While 1

$msg1 = GUIGetMsg()

    If GuiCtrlRead($Input1) And GuiCtrlRead($Input3) And GuiCtrlRead($Input4) And GuiCtrlRead($Input5) <> "" And $Enabled = False Then
            GuiCtrlSetState($Btn_OK, $GUI_ENABLE)
            $Enabled = True
        EndIf

    Select

        Case $msg1 = $Btn_OK
             $InputOfInputBoxDataBaseName = GUICtrlRead($Input1)
             $InputOfInputBoxIP = GUICtrlRead($Input2)
             $InputOfInputBoxHostName = GUICtrlRead($Input3)
             $InputOfInputBoxUserName = GUICtrlRead($Input4)
             $InputOfInputBoxPassword = GUICtrlRead($Input5)
             $RetValue = True
             ExitLoop

        Case $msg1 = $GUI_EVENT_CLOSE

            ExitLoop

    EndSelect

WEnd

    GuiDelete($InputWindowHandle)
    WinWaitClose("Provide Details")
    Opt("GUIOnEventMode",1)



EndFunc
Edited by randeep

[font="Palatino Linotype"]Randeep Singh[/font][sub][/sub]

Share this post


Link to post
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
Sign in to follow this  

×