Sign in to follow this  
Followers 0
pionner

create a "quick search" listbox under an inputbox

7 posts in this topic

hello:

Am trying to insert a listbox under an inputbox, the idea is that when the user write a letter or any string value, then automatically appear the listbox with the matching results.

I was traying to accomplish, but when I insert something it doesn´t stop to flashing.

all your comments about it will be appreciated!

my code

#include [/size]
#include 
#include 
#include 
#include 
#Include 

global $dato, $handle


$hGUI = GUICreate("tester ahora",400,400)
$input1 = GUICtrlCreateInput("",0,0,200)



$handle = GUICtrlcreateList("hola",0,22,200,100)
GUICtrlSetState($handle,$GUI_HIDE)

GUISetState()

while 1
$nmg = GUIGetMsg()

Switch $nmg
case $GUI_EVENT_CLOSE
exit
Case GUICtrlRead($input1)
Switch GUICtrlRead($input1)
case ""
GUICtrlSetState($handle,$GUI_HIDE)
case Else
GUICtrlSetState($handle,$GUI_SHOw)
EndSwitch
EndSwitch

WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

do a check that the state isn't as expected prior to setting the state

Global $dato, $handle

$hGUI = GUICreate("tester ahora", 400, 400)
$input1 = GUICtrlCreateInput("", 0, 0, 200)

$handle = GUICtrlCreateList("hola", 0, 22, 200, 100)
GUICtrlSetState($handle, $GUI_HIDE)
GUISetState()
While 1
 $nmg = GUIGetMsg()
 If $nmg = $GUI_EVENT_CLOSE Then Exit
 If GUICtrlRead($input1) = "" Then
;~   ConsoleWrite(GUICtrlGetState($handle) & " " & $GUI_HIDE & @CRLF)
  If BitAND(GUICtrlGetState($handle), $GUI_SHOW) Then GUICtrlSetState($handle, $GUI_HIDE)
 Else
;~   ConsoleWrite(GUICtrlGetState($handle) & " " & $GUI_SHOW & @CRLF)
  If BitAND(GUICtrlGetState($handle), $GUI_HIDE) Then GUICtrlSetState($handle, $GUI_SHOW)
 EndIf
WEnd
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

pionner,

I wrote this a while ago - it might give you some ideas: ;)

#include <GUIConstantsEx.au3>

Global $hGUI, $hInput, $hList, $sData, $asKeyWords[100]

Keywords()

$hGUI = GUICreate("Begin with B", 200, 400)
$hInput = GUICtrlCreateInput("", 5, 5, 190, 20)
$hList = GUICtrlCreateList("", 5, 30, 190, 365, BitOR(0x00100000, 0x00200000))
GUICtrlSetState(-1, $GUI_HIDE)
GUISetState(@SW_SHOW, $hGUI)

$sCurr_Input = ""
$sData = "|"

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hList
            $sChosen = GUICtrlRead($hList)
            If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen)
    EndSwitch

    ; Show/hide list depending on input content and list data
    If GUICtrlRead($hInput) <> "" And BitAND(GUICtrlGetState($hList), $GUI_HIDE) = $GUI_HIDE And $sData <> "|" Then GUICtrlSetState($hList, $GUI_SHOW)
    If GUICtrlRead($hInput) = "" And BitAND(GUICtrlGetState($hList), $GUI_SHOW) = $GUI_SHOW Then GUICtrlSetState($hList, $GUI_HIDE)

    ; If input has changed, refill list with matching items
    If GUICtrlRead($hInput) <> $sCurr_Input Then
        CheckInputText()
        $sCurr_Input = GUICtrlRead($hInput)
    EndIf

WEnd

Func Keywords()

    ; Only items beginning with B created - so able to see what happens when list holds nothing (hides) or lots of data (scrolls)
    For $i = 0 To 99
        $asKeyWords[$i] = "B" & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1))
        $sData &= $asKeyWords[$i] & "|"
    Next
    GUICtrlSetData($hList, $sData)
EndFunc   ;==>Keywords

Func CheckInputText()
    $l = StringLen(GUICtrlRead($hInput))
    $sData = "|" ; Start with delimiter so new data always replaces aold
    Local $sInput = GUICtrlRead($hInput)
    If $sInput <> "" Then
        For $i = 0 To 99
            If StringLeft($asKeyWords[$i], $l) = $sInput Then $sData &= $asKeyWords[$i] & "|"
        Next
        GUICtrlSetData($hList, $sData)
    EndIf
EndFunc   ;==>CheckInputText

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

hey you two ... you are awsome!!!!!!!!!

how can i pay your help in this.!!!

cheers!! :thumbsup: :thumbsup:

:thumbsup:

:thumbsup:

Share this post


Link to post
Share on other sites

how can i pay your help in this.!!!

By donating either your time in helping others or money to the AutoIt project and its developers.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

is a UDF written by Jscript

If you want for Edit/RichEdit Control check my signature

Regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

phoenix:

thanks men for your post, just one more question.

I have a tab form, but even if I try to set the list box, it does not appear unless I force it to appear by doing click on the inputbox.

entire code attached, but I dont have the DB avaiable

#AutoIt3Wrapper_Compression=0       ;Compression parameter 0-4  0=Low 2=normal 4=High. Default=2
#AutoIt3Wrapper_UseUpx=n    ;(Y/N) Compress output program.  Default=Y


#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIImagelist.au3>
#Include <GuiListView.au3>
#Include <GuiListBox.au3>
#include <IE.au3>
#include <SendMessage.au3>
#include <ScreenCapture.au3>
#include <Guicomboboxex.au3>
#include <String.au3>


;Especiales
#include <MySql.au3>
#include <GoogleMapsEx2.au3>
#include <GUItab.au3>
#include <Excel.au3>
#include "_UskinLibrary.au3"
;--
_Uskin_LoadDLL()
_USkin_Init("C:\Program Files (x86)\AutoIt3\Include\Skins\cosmo.msstyles");




HotKeySet("!b","_Screen_Shot")
;HotKeySet("!c","Import_From_Excel")


Dim $flag = @DesktopDir & "\ico\Flag-of-"
Dim $msg, $distance, $duration
Global $gmap_ctrl,$main_gui, $set_view_button, $set_view_input, $zoom_view_button, $zoom_view_input, $add_marker_button, $add_marker_input,$stext, $Sec_Gui
Global $gmap, $AsWords[100], $hList, $sData, $x, $num
Global $sql, $Form1_1, $Input1, $combo_set1


$Form1_1 = GUICreate("TerSys - Sistema de Gestión de Territorios", 959, 480, 190, 122)
GUISetFont(8, 400, 0, "Arial")
RemoveStupidBlaklines($Form1_1)

$gmap_ctrl = _GUICtrlGoogleMap_Create($gmap,0,0,538,480,"Guaraparí, Espirito Santo, Brazil")

GUISetFont(8, 400, 0, "Arial")

GUICtrlSetResizing($gmap_ctrl, $GUI_DOCKTOP)


$sql = _MySQLConnect("root","pionner","DB_Territorio","localhost")
$Tab1 = GUICtrlCreateTab(536, 0, 417, 481)

;****************** INGRESO **********************
$TabSheet1 = GUICtrlCreateTabItem("Personas  ")
$Input1 = GUICtrlCreateInput("", 560, 136, 161, 21)
$Input2 = GUICtrlCreateInput("", 560, 184, 89, 21)
$Label1 = GUICtrlCreateLabel("Dirección", 560, 160, 49, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label2 = GUICtrlCreateLabel("Pais Procedencia", 744, 112, 87, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$comex = _GUICtrlComboBoxEx_Create($Form1_1, "", 740, 136, 163, 200)
$iList = _GUIImageList_Create(16, 16, 5, 3)

_GUIImageList_AddIcon($iList, $flag & "Argentina.ico")
_GUIImageList_AddIcon($iList, $flag & "Bolivia.ico")
_GUIImageList_AddIcon($iList, $flag & "Brazil.ico")
_GUIImageList_AddIcon($iList, $flag & "Chile.ico")
_GUIImageList_AddIcon($iList, $flag & "Colombia.ico")
_GUIImageList_AddIcon($iList, $flag & "Costa-Rica.ico")
_GUIImageList_AddIcon($iList, $flag & "Cuba.ico")
_GUIImageList_AddIcon($iList, $flag & "Ecuador.ico")
_GUIImageList_AddIcon($iList, $flag & "El-Salvador.ico")
_GUIImageList_AddIcon($iList, $flag & "Spain.ico")
_GUIImageList_AddIcon($iList, $flag & "France.ico")
_GUIImageList_AddIcon($iList, $flag & "Guatemala.ico")
_GUIImageList_AddIcon($iList, $flag & "Honduras.ico")
_GUIImageList_AddIcon($iList, $flag & "Japan.ico")
_GUIImageList_AddIcon($iList, $flag & "libano.ico")
_GUIImageList_AddIcon($iList, $flag & "Mexico.ico")
_GUIImageList_AddIcon($iList, $flag & "Nicaragua.ico")
_GUIImageList_AddIcon($iList, $flag & "Panama.ico")
_GUIImageList_AddIcon($iList, $flag & "Paraguay.ico")
_GUIImageList_AddIcon($iList, $flag & "Peru.ico")
_GUIImageList_AddIcon($iList, $flag & "Puerto-Rico.ico")
_GUIImageList_AddIcon($iList, $flag & "Republica Dominicana.ico")
_GUIImageList_AddIcon($iList, $flag & "Switzerland.ico")
_GUIImageList_AddIcon($iList, $flag & "Uruguay.ico")
_GUIImageList_AddIcon($iList, $flag & "Timor-Leste.ico")
_GUIImageList_AddIcon($iList, $flag & "Venezuela.ico")

Local $total = _GUICtrlComboBoxEx_SetImageList($comex, $iList)

_GUICtrlComboBoxEx_AddString($comex, "Argentina", 0, 0)
_GUICtrlComboBoxEx_AddString($comex, "Bolivia", 1, 1)
_GUICtrlComboBoxEx_AddString($comex, "Brasil", 2, 2)
_GUICtrlComboBoxEx_AddString($comex, "Chile", 3, 3)
_GUICtrlComboBoxEx_AddString($comex, "Colombia", 4, 4)
_GUICtrlComboBoxEx_AddString($comex, "Costa-Rica", 5, 5)
_GUICtrlComboBoxEx_AddString($comex, "Cuba", 6, 6)
_GUICtrlComboBoxEx_AddString($comex, "Ecuador", 7, 7)
_GUICtrlComboBoxEx_AddString($comex, "El Salvador", 8, 8)
_GUICtrlComboBoxEx_AddString($comex, "España", 9, 9)
_GUICtrlComboBoxEx_AddString($comex, "Francia", 10, 10)
_GUICtrlComboBoxEx_AddString($comex, "Guatemala", 11, 11)
_GUICtrlComboBoxEx_AddString($comex, "Honduras", 12, 12)
_GUICtrlComboBoxEx_AddString($comex, "Japón", 13, 13)
_GUICtrlComboBoxEx_AddString($comex, "Líbano", 14, 14)
_GUICtrlComboBoxEx_AddString($comex, "Mexico",15 , 15)
_GUICtrlComboBoxEx_AddString($comex, "Nicaragua", 16, 16)
_GUICtrlComboBoxEx_AddString($comex, "Panamá", 17, 17)
_GUICtrlComboBoxEx_AddString($comex, "Paraguay",18, 18)
_GUICtrlComboBoxEx_AddString($comex, "Peru", 19, 19)
_GUICtrlComboBoxEx_AddString($comex, "Puerto Rico", 20, 20)
_GUICtrlComboBoxEx_AddString($comex, "Republica Dominicana", 21, 21)
_GUICtrlComboBoxEx_AddString($comex, "Suiza", 22, 22)
_GUICtrlComboBoxEx_AddString($comex, "Uruguay", 23, 23)
_GUICtrlComboBoxEx_AddString($comex, "Timor Oriental", 24, 24)
_GUICtrlComboBoxEx_AddString($comex, "Venezuela", 25, 25)

$Label3 = GUICtrlCreateLabel("Ciudad", 560, 216, 37, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Label4 = GUICtrlCreateLabel("Nombre de la Persona", 560, 112, 110, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


$Label5 = GUICtrlCreateLabel("Tipo de Vivienda", 832, 160, 84, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Input4 = GUICtrlCreateInput("", 832, 184, 89, 21)


$Label6 = GUICtrlCreateLabel("Número", 672, 160, 41, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


$Input5 = GUICtrlCreateInput("", 672, 184, 65, 21)


$Label7 = GUICtrlCreateLabel("Publicador Asignado", 728, 216, 103, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


$input17=GUICtrlCreateInput("", 728, 240, 185, 21)

$Label8 = GUICtrlCreateLabel("Observaciones", 552, 336, 79, 19)
$observ = GUICtrlCreateEdit("", 552, 360, 385, 65, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
GUICtrlSetFont(-1, 8, 400, 0, "@Arial Unicode MS")

$Label9 = GUICtrlCreateLabel("Numero de Contacto", 560, 264, 102, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$tel =GUICtrlCreateInput("", 560, 288, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))


$Button1 = GUICtrlCreateButton("Generar Reporte", 840, 440, 100, 25)
$Button2 = GUICtrlCreateButton("Aceptar", 680, 440, 75, 25)
$Geo_localizar = GUICtrlCreateButton("Geo-Localizar",550, 440, 85, 25)



$ciudad = GUICtrlCreateCombo("", 560, 240, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Anchieta|Iconia|Guaraparí|Piuma")

$Label18 = GUICtrlCreateLabel("E-Mail", 728, 264, 32, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$input26 = GUICtrlCreateInput("", 728, 288, 193, 21)

$Group1 = GUICtrlCreateGroup("Modalidad", 552, 40, 161, 41)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

$Radio3 = GUICtrlCreateRadio("", 560, 56, 17, 17)
GUICtrlSetState($Radio3, $GUI_CHECKED)



$Radio4 = GUICtrlCreateRadio("", 640, 56, 17, 17)


$Label19 = GUICtrlCreateLabel("Consulta", 584, 56, 46, 18)
$Label20 = GUICtrlCreateLabel("Ingreso", 664, 56, 40, 18)
$Barrio=GUICtrlCreateInput("", 744, 184, 73, 22)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$Label34 = GUICtrlCreateLabel("Barrio", 744, 160, 33, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)

;initial state
                        GUICtrlSetState($Input2, $GUI_DISABLE)
                        GUICtrlSetState($Input5, $GUI_DISABLE)
                        GUICtrlSetState($Input4, $GUI_DISABLE)
                        GUICtrlSetState($Barrio, $GUI_DISABLE)
                        GUICtrlSetState($ciudad, $GUI_DISABLE)
                        GUICtrlSetState($Input17, $GUI_DISABLE)
                        GUICtrlSetState($Tel, $GUI_DISABLE)
                        GUICtrlSetState($Input26, $GUI_DISABLE)
                        GUICtrlSetState($observ, $GUI_DISABLE)

$Group2 = GUICtrlCreateGroup("Datos",552, 88, 385, 233)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

;******************* INGRESO *****************************
;*********************************************************


;*********************************************************
; ***************TERRITORIO ******************************




$TabSheet2 = GUICtrlCreateTabItem("Territorios")

$Label10 = GUICtrlCreateLabel("N° Territorio", 552, 45, 61, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$numero_territorio = GUICtrlCreateInput("", 552, 60, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))



;nombre Territorio
$Nom_terr = GUICtrlCreateInput("", 552, 100,90, 21)
$Label16 = GUICtrlCreateLabel("Nombre", 552, 86, 105, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

;Estado
$estado = GUICtrlCreateInput("", 650, 100, 33, 22)
$Label36 = GUICtrlCreateLabel("Estado", 650, 86, 37, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

;ciudad
$ciudad1 = GUICtrlCreateCombo("", 695, 100, 89, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Anchieta|Guaraparí|Iconio|Piuma")
$Label14 = GUICtrlCreateLabel("Ciudad", 695, 86, 37, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


;barrio
$Barrio_terr = GUICtrlCreateInput("", 810, 100, 100, 21)
$Label15 = GUICtrlCreateLabel("Barrio", 810, 86, 33, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")





$Group6 = GUICtrlCreateGroup("Diseñar Mapa",544, 135, 377, 60)
$Cord = GUICtrlCreateButton("ing manzana", 560, 160, 75, 25)
$ing_territorio = GUICtrlCreateButton("ing Terr", 640, 160, 75, 25)
;num manzanas
$n_manzanas = GUICtrlCreateInput("", 720, 160, 41, 22)
$Label26 = GUICtrlCreateLabel("N° Manzanas", 720, 146, 68, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")




$Radio1 = GUICtrlCreateRadio("", 768, 48, 17, 17)
$Radio2 = GUICtrlCreateRadio("", 840, 48, 17, 17)

$Label12 = GUICtrlCreateLabel("Ingreso", 864, 48, 40, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label13 = GUICtrlCreateLabel("Consulta", 792, 48, 46, 18)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")






$Group3 = GUICtrlCreateGroup("Datos del Territorio", 544, 32, 377, 100)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")

GUICtrlCreateGroup("", -99, -99, 1, 1)

$delete = GUICtrlCreateButton("Modificar", 688, 424, 75, 25)
$Button5 = GUICtrlCreateButton("Ingresar", 768, 424, 75, 25)




$graficar_mapa = GUICtrlCreateGroup("Graficar Mapa",544, 210, 377, 60)
$Plano_Censo = GUICtrlCreateButton("Mapa Censo", 560, 235, 75, 25)
$Graficar = GUICtrlCreateButton("Mapa Integral", 640, 235, 75, 25)
$Graficar_Single = GUICtrlCreateButton("Mapa Inv.", 720, 235, 75, 25)
GUICtrlCreateLabel("Territorios",810,220)
$Graficar_Single_input = GUICtrlCreateInput("",810,235,35,22,$ES_NUMBER)

GUICtrlSetFont(-1, 8, 400, 0, "Arial")


GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group7 = GUICtrlCreateGroup("Estadisticas Seglares", 544, 290, 377, 120)
GUICtrlCreateGroup("", -99, -99, 1, 1)


GUICtrlSetData($n_manzanas,1)


;*************************** TERRITORIOS ***********************************
;***************************************************************************


$TabSheet3 = GUICtrlCreateTabItem("Informes ")
$Group5 = GUICtrlCreateGroup("Tipo de Informes", 544, 40, 377, 185)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio5 = GUICtrlCreateRadio("", 560, 64, 17, 17)
$Radio6 = GUICtrlCreateRadio("", 560, 88, 17, 17)
$Radio7 = GUICtrlCreateRadio("", 560, 112, 17, 17)
$Radio8 = GUICtrlCreateRadio("", 560, 136, 17, 17)
$Label11 = GUICtrlCreateLabel("Tarjeta Completa", 584, 64, 84, 18)
$Label17 = GUICtrlCreateLabel("Tarjeta Por Territorio", 584, 88, 102, 18)
$Label21 = GUICtrlCreateLabel("Grafico Trabajo ", 584, 112, 82, 18)
$Label22 = GUICtrlCreateLabel("Consulta Por Periodos", 584, 136, 110, 18)
$Date1 = GUICtrlCreateDate("2013/03/06 12:38:39", 680, 192, 106, 21, 0)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
$Date2 = GUICtrlCreateDate("2013/03/06 12:38:48", 560, 192, 106, 21, 0)
GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif")
GUICtrlCreateInput("", 736, 80, 49, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
$Label23 = GUICtrlCreateLabel("Territorio", 736, 56, 47, 18)
$Label24 = GUICtrlCreateLabel("Desde", 560, 168, 35, 18)
$Label25 = GUICtrlCreateLabel("Hasta", 680, 168, 32, 18)
$Button6 = GUICtrlCreateButton("Previsualizar", 832, 64, 75, 25)
$Button7 = GUICtrlCreateButton("Imprimir", 832, 96, 75, 25)
$Button8 = GUICtrlCreateButton("Exportar", 832, 128, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Informacion Condensada", 544, 240, 377, 193)
$Edit1 = GUICtrlCreateEdit("", 552, 264, 169, 161)
GUICtrlSetData(-1, "Edit1")
$Edit2 = GUICtrlCreateEdit("", 744, 264, 169, 161)
GUICtrlSetData(-1, "Edit2")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet4 = GUICtrlCreateTabItem("Tarjetas de Territorio")
$Group8 = GUICtrlCreateGroup("Ingreso Trabajo Territorios", 544, 32, 225, 137)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$numero = GUICtrlCreateInput("", 616, 56, 80, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
$capitan = GUICtrlCreateInput("", 616, 80, 80, 22)
$manzana = GUICtrlCreateInput("", 616, 104, 80, 22)


$Label27 = GUICtrlCreateLabel("Numero", 552, 56, 41, 18)
$Label28 = GUICtrlCreateLabel("Capitan", 552, 80, 40, 18)
$Label29 = GUICtrlCreateLabel("Manzanas", 552, 104, 54, 18)
$Label30 = GUICtrlCreateLabel("Dia Hecho", 552, 128, 53, 18)
$Date3 = GUICtrlCreateDate("2013/03/06 21:26:48", 616, 128, 82, 22, 0)
$Ing_tra_terr = GUICtrlCreateButton("", 720, 56, 35, 33)
GUICtrlSetBkColor(-1, 0xC0C0C0)
$Button10 = GUICtrlCreateButton("", 720, 88, 35, 33)
$Button11 = GUICtrlCreateButton("", 720, 120, 35, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group9 = GUICtrlCreateGroup("Imprimir Tarjetas", 776, 32, 169, 137)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Radio9 = GUICtrlCreateRadio("", 784, 56, 17, 17)
$Radio10 = GUICtrlCreateRadio("", 784, 80, 17, 17)
$Label31 = GUICtrlCreateLabel("Juego Completo", 808, 56, 80, 18)
$Label32 = GUICtrlCreateLabel("Individuales", 808, 80, 60, 18)
GUICtrlCreateInput("", 784, 128, 57, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlSetLimit(-1, 2)
$Label33 = GUICtrlCreateLabel("Territorios", 784, 104, 53, 18)
$Label35 = GUICtrlCreateLabel("", 832, 112, 4, 4)
$Checkbox1 = GUICtrlCreateCheckbox("Historial", 856, 136, 81, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Estadisticas", 856, 112, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group10 = GUICtrlCreateGroup("Previsualización", 720, 176, 217, 257)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button12 = GUICtrlCreateButton("Vista Previa", 840, 448, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Button13 = GUICtrlCreateButton("Imprimir", 560, 448, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Group11 = GUICtrlCreateGroup("Tarjetas por Personas", 544, 176, 161, 265)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$TabSheet5 = GUICtrlCreateTabItem("Grupos Predicación")
$Group12 = GUICtrlCreateGroup("Diseño Programa", 552, 32, 385, 233)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label39 = GUICtrlCreateLabel("Lunes", 560, 80, 34, 18)
$Label40 = GUICtrlCreateLabel("Martes", 560, 104, 37, 18)
$Label41 = GUICtrlCreateLabel("Miercoles", 560, 128, 50, 18)
$Label42 = GUICtrlCreateLabel("Jueves", 560, 152, 39, 18)
$Label43 = GUICtrlCreateLabel("Viernes", 560, 176, 42, 18)
$Label44 = GUICtrlCreateLabel("Sabado", 560, 200, 41, 18)
$Label45 = GUICtrlCreateLabel("Domingo", 560, 224, 45, 18)


$cvals = _GetcolVals($sql,"fam_pub","nombre_familia")

_ArrayPush($cvals,"")
$Combo_set1 = _ArrayToString($cvals,"|")


$Combo1 = GUICtrlCreateCombo("", 616, 80, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo2 = GUICtrlCreateCombo("", 616, 104, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo3 = GUICtrlCreateCombo("", 616, 128, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo4 = GUICtrlCreateCombo("", 616, 152, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo5 = GUICtrlCreateCombo("", 616, 176, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo6 = GUICtrlCreateCombo("", 616, 200, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)
$Combo7 = GUICtrlCreateCombo("", 616, 224, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1,$Combo_set1)




$Label46 = GUICtrlCreateLabel("Dias Especiales", 792, 56, 80, 18)
$Date4 = GUICtrlCreateDate("2013/04/27 14:17:21", 792, 80, 82, 22, 0)
$Label47 = GUICtrlCreateLabel("Visita Superintendente", 792, 104, 113, 18)
$Label48 = GUICtrlCreateLabel("desde", 792, 128, 34, 18)
$Date5 = GUICtrlCreateDate("2013/04/27 14:20:21", 792, 152, 82, 22, 0)
$Button14 = GUICtrlCreateButton("Gmail", 784, 216, 40, 33)
$Button15 = GUICtrlCreateButton("PDF", 832, 216, 40, 33)
$Button16 = GUICtrlCreateButton("Excel", 880, 216, 40, 33)
$Label52 = GUICtrlCreateLabel("Territorios", 720, 56, 53, 18)

$Input8 = GUICtrlCreateInput("", 720, 80, 57, 22)
$Input9 = GUICtrlCreateInput("", 720, 104, 57, 22)
$Input10 = GUICtrlCreateInput("", 720, 128, 57, 22)
$Input11 = GUICtrlCreateInput("", 720, 152, 57, 22)
$Input12 = GUICtrlCreateInput("", 720, 176, 57, 22)
$Input13 = GUICtrlCreateInput("", 720, 200, 57, 22)
$Input14 = GUICtrlCreateInput("", 720, 224, 57, 22)

$Label53 = GUICtrlCreateLabel("Dias", 560, 56, 25, 18)
$Label54 = GUICtrlCreateLabel("Lugar", 640, 56, 32, 18)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group13 = GUICtrlCreateGroup("Ingresar Familia", 552, 272, 385, 73)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label49 = GUICtrlCreateLabel("Nombre Familia", 560, 288, 76, 18)
$Label50 = GUICtrlCreateLabel("Telefono", 784, 288, 46, 18)
$Label51 = GUICtrlCreateLabel("Direccion Exacta", 656, 288, 85, 18)
$nfam = GUICtrlCreateInput("", 560, 312, 81, 22)
$telfam = GUICtrlCreateInput("", 784, 312, 73, 22)
$Dirfam = GUICtrlCreateInput("", 656, 312, 121, 22)
$ingfam = GUICtrlCreateButton("ingresar",864,312,65,25)

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateTabItem("")

$sql = _MySQLConnect("root","pionner","DB_Territorio","localhost")

GUISetState(@SW_SHOW,$Form1_1)
GUISetAccelerators($Form1_1)



While 1


    $nMsg = GUIGetMsg(1)


    Switch $nMsg [1]
        Case $Form1_1
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                    _MySQLend($sql)
                Case $Button1
                    _Report()
                Case $Button2
                    _Ing_per()
                Case $Geo_localizar
                    Insert_Coor_per()
                Case $Cord
                    _Coordenates()
                Case $Plano_Censo
                    _Planos_Censo()
                Case $Ing_tra_terr
                    Ing_Tra_Terr()
                 Case $ing_territorio
                    _insert_Territorio()
                Case $Graficar
                    All_Ter()
                Case $delete
                    Insert_Coor_per()
                Case $Graficar_Single
                    Single_ter()
                Case $ingfam
                    ing_fam()
                Case $Tab1
            Switch GUICtrlRead($Tab1)
                Case 0
                    WinSetState($comex, "", @SW_SHOW)
                Case Else
                    WinSetState($comex, "", @SW_HIDE)
            EndSwitch

            Case $Radio3
                Switch Guictrlread($Radio3)
                    Case $GUI_CHECKED
                        GUICtrlSetState($Input2, $GUI_DISABLE)
                        GUICtrlSetState($Input5, $GUI_DISABLE)
                        GUICtrlSetState($Input4, $GUI_DISABLE)
                        GUICtrlSetState($Barrio, $GUI_DISABLE)
                        GUICtrlSetState($ciudad, $GUI_DISABLE)
                        GUICtrlSetState($Input17, $GUI_DISABLE)
                        GUICtrlSetState($Tel, $GUI_DISABLE)
                        GUICtrlSetState($Input26, $GUI_DISABLE)
                        GUICtrlSetState($observ, $GUI_DISABLE)

                    Case $GUI_UNCHECKED

                        GUICtrlSetState($Input2, $GUI_ENABLE)
                        GUICtrlSetState($Input5, $GUI_ENABLE)
                        GUICtrlSetState($Input4, $GUI_ENABLE)
                        GUICtrlSetState($Barrio, $GUI_ENABLE)
                        GUICtrlSetState($ciudad, $GUI_ENABLE)
                        GUICtrlSetState($Input17, $GUI_ENABLE)
                        GUICtrlSetState($Tel, $GUI_ENABLE)
                        GUICtrlSetState($Input26, $GUI_ENABLE)
                        GUICtrlSetState($observ, $GUI_ENABLE)

                EndSwitch

            Case $Radio4
                Switch Guictrlread($Radio4)

                    Case $GUI_CHECKED

                        GUICtrlSetState($Input2, $GUI_ENABLE)
                        GUICtrlSetState($Input5, $GUI_ENABLE)
                        GUICtrlSetState($Input4, $GUI_ENABLE)
                        GUICtrlSetState($Barrio, $GUI_ENABLE)
                        GUICtrlSetState($ciudad, $GUI_ENABLE)
                        GUICtrlSetState($Input17, $GUI_ENABLE)
                        GUICtrlSetState($Tel, $GUI_ENABLE)
                        GUICtrlSetState($Input26, $GUI_ENABLE)
                        GUICtrlSetState($observ, $GUI_ENABLE)

                    Case $GUI_UNCHECKED

                        GUICtrlSetState($Input2, $GUI_DISABLE)
                        GUICtrlSetState($Input5, $GUI_DISABLE)
                        GUICtrlSetState($Input4, $GUI_DISABLE)
                        GUICtrlSetState($Barrio, $GUI_DISABLE)
                        GUICtrlSetState($ciudad, $GUI_DISABLE)
                        GUICtrlSetState($Input17, $GUI_DISABLE)
                        GUICtrlSetState($Tel, $GUI_DISABLE)
                        GUICtrlSetState($Input26, $GUI_DISABLE)
                        GUICtrlSetState($observ, $GUI_DISABLE)

                EndSwitch
            EndSwitch

        Case $Sec_Gui
            Switch $nMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($Sec_Gui)
            EndSwitch

     EndSwitch


WEnd



; Funciones de La DB MySql

Func _Ing_per()

            Local $item = _GUICtrlComboBoxEx_GetCurSel($comex)

                local $texto = _GUICtrlComboBoxEx_GetItemText($comex,$item,$stext)

                dim $data1 [12]

                $data1 [0] = "Nombre_persona"
                $data1 [1] = "Pais"
                $data1 [2] = "Direccion"
                $data1 [3] = "Numero"
                $data1 [4] = "Tipo_de_vi"
                $data1 [5] = "Ciudad"
                $data1 [6] = "Barrio"
                $data1 [7] = "Pub_asig"
                $data1 [8] = "Tel"
                $data1 [9] = "Email"
                $data1 [10] = "Obs"
                $data1 [11] = ""

                dim $ar1 [12]

                $ar1[0]= GUICtrlRead($Input1);nombre de la persona
                $ar1[1]= $stext;nacionalidad
                $ar1[2]= GUICtrlRead($Input2) ; dirección
                $ar1[3]= GUICtrlRead($Input5);numero de casa
                $ar1[4]= GUICtrlRead($input4);tipo de vivienda
                $ar1[5]= GUICtrlRead($ciudad) ;Ciudad
                $ar1[6]= GUICtrlRead($Barrio);barrio
                $ar1[7]= GUICtrlRead($input17) ;publicador Asignado
                $ar1[8]= GUICtrlRead($tel) ;telefono
                $ar1[9]= GUICtrlRead($input26);e-mail
                $ar1[10]= GUICtrlRead($observ) ;observaciones
                $ar1[11]=""

        _AddRecord($sql,'Personas', $data1, $ar1)

MsgBox (0,"territorios","persona registrada con exito")

$address_maestro = Guictrlread($Input2) & " " & Guictrlread($Input5) & ", " & Guictrlread($Barrio) & ", " & Guictrlread($ciudad) & ", Espirito Santo, Brasil"

;_MySQLEnd($sql)

                GUICtrlSetData($Input1,"")
                GUICtrlSetData($Input2,"")
                GUICtrlSetData($Input5,"")
                GUICtrlSetData($input4,"")
                GUICtrlSetData($ciudad,"")
                GUICtrlSetData($Barrio,"")
                GUICtrlSetData($Input17,"")
                GUICtrlSetData($tel,"")
                GUICtrlSetData($input26,"")
                GUICtrlSetData($observ,"")

$cor_personas = _GUICtrlGoogleMap_GetLatLng($address_maestro)

$past = $cor_personas[0] & "," & $cor_personas[1]

_Query($sql, "UPDATE personas SET `coordenadas`='" & $past & "'  WHERE codigo= LAST_INSERT_ID()")

ToolTip("LatLng Añadido Con Exito",950,690,"TerSys - LatLng Manager")
sleep(2000)

EndFunc

;REPORTE

Func _Report()

if GUICtrlRead($Input1) = "" then

        MsgBox (0,"Territories","Debe Ingresar un Nombre")

Else

;-----------Modulo de Consulta-----------------------



    $nombre = Guictrlread($Input1)

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

$Sec_Gui = GUICreate("Reporte",800,600,-1,-1)
GUISetState(@SW_SHOW)

local $insetBorders, $i
Local $item = _GUICtrlComboBoxEx_GetCurSel($comex)
local $texto = _GUICtrlComboBoxEx_GetItemText($comex,$item,$stext)

           $IEobj =_IECreateEmbedded ()
           $gui_obj = GUICtrlCreateObj($IEobj,0,0,850,600)

            _IENavigate($IEobj,@DesktopDir & "\Reportes\report_model.html")
                $Body = _IETagNameGetCollection($IEobj,"body",0)
                    $_Getcolvals = _GetcolVals($sql,"personas order by barrio", "codigo")
                       $ubound = _CountRecords($sql,"personas","codigo")

    for $n = 0  to $ubound

    $query_personas = "Select distinct codigo, Nombre_persona, pais, Direccion, Numero, tipo_de_vi, Barrio, pub_asig, obs " & _
    "from db_territorio.personas where codigo = " & $_Getcolvals[$n] & " "

    $Qp = _Query($sql,$query_personas)

        with $Qp
            $val1 = .fields("Nombre_persona").value
            $val2 = .fields("Pais").value
            $val3 = .fields("Direccion").value
            $val4 = .fields("tipo_de_vi").value
            $val7 = .fields("Barrio").value
            $val8 = .fields("numero").value
            $val5 = .fields("pub_asig").value
            $val6 = .fields("Obs").value
        EndWith

         if Mod($n,2)= 0 then

         _IEDocInsertHTML($Body , "<section id=""content"" >" & @CRLF & _
        "<aside id= ""no"" >"  & @CRLF & _
               " <div>" & @CRLF & _
                    "<div>" & @CRLF & _
                       " <b id=""title"" >" & $val1 & " (Barrio: " & $val7 & ")</b>" & @CRLF & _
                    "</div>" & @CRLF & _
                  " <p>Direccion:" & $val3 & " N°" & $val8 & "</p>" & @CRLF & _
                   "<p>tipo de vivienda:" &   $val4 &  "</p>" & @CRLF & _
                   "<p id=""ref"">Referencias:" &  $val6 &  "<p>" & @CRLF & _
                "</div>" & @CRLF & _
                "<div>"& @CRLF & _
                  "<p>Pais:" &  $val2 &  "</p>" & @CRLF & _
                  "<p>Datos de contacto:</p>" & @CRLF & _
                "</div>" & @CRLF & _
      "</aside>" )

        Else

        _IEDocInsertHTML($Body , " <aside id=""no"">" & @CRLF & _
                "<div>" & @CRLF & _
                   " <div>" & @CRLF & _
                       "<b id=""title"">" & $val1 & " (Barrio: " & $val7 & ")</b>" & @CRLF & _
                    "</div>" & @CRLF & _
                  "<p>Direccion:" & $val3 & " N°" & $val8 & "</p>"  & @CRLF & _
                  "<p>tipo de vivienda: " & $val4 & " </p>" & @CRLF & _
                  "<p id=""ref"">Referencias: " &  $val6 & "<p>" & @CRLF & _
                "</div>" & @CRLF & _
                "<div>" & @CRLF & _
                  "<p>Pais:" & $val2 & "</p>" & @CRLF & _
                  "<p>Datos de contacto:</p>" & @CRLF & _
                "</div>" & @CRLF & _
   "</aside>" & @CRLF & _
   "</section>")

                         EndIf
        Next

$IEobj.document.body.scroll = "yes"

Return $IEobj

GUISetState()

EndIf

EndFunc

Func All_Ter()

    $ubound2 = _CountRecords($sql,"planos","coordenadas")

    for $num = 1 to $ubound2

    local $UBound =_CountRecords($sql,"planos where id_territorio = " & $num, "coordenadas")

For $i = 1 to $Ubound
    $ST=_Query ($sql,"Select Coordenadas from Planos where id_territorio = " & $num & " And num_manzana = " & $i)

    with $ST
        $CTS= .fields("coordenadas").value
    endwith

    _GUICtrlGoogleMap_DrawPolygon($gmap,$CTS,'#000000','#000000')
Next
Next

    EndFunc

Func _addmarcador()

    if GUICtrlRead($Input1) = "" then

        MsgBox (0,"Territories","Debe Ingresar un Nombre")

         Else

        $query =_Query($sql, "SELECT DISTINCT direccion, numero, ciudad  FROM db_territorio.personas where Nombre_persona = '" & Guictrlread($input1) & "'")

            with $query
                $address = .fields("direccion").value
                $number = .fields("numero").value
                $city = .fields("ciudad").value
            EndWith

    _GUICtrlGoogleMap_AddMarker($gmap, $address & ", " & $number & ", " & $city & " - Espirito Santo, Brazil")

    EndIf

EndFunc



Func _Print_Capture()

    _IEAction($gmap,"printdefault")

EndFunc


Func _Coordenates()
    ; get IE Elements

   local $x, $Colnames, $array

if GUICtrlRead($numero_territorio) = "" then
    MsgBox(0,"TerSys","Por Favor Ingrese un numero de Territorio")
Else

    $object =_IEFormGetObjByName($gmap,"map_form")
    $IEinput = _IEFormElementGetObjByName($object,"vertices")
    $coordenadas = _IEFormElementGetValue($IEinput)

            ;set Values in databases
            ;1st create an array

            dim $array[4]

            $array[0] = GUICtrlRead($numero_territorio)
            $array[1] = GUICtrlRead($n_manzanas)
            $array[2] = $coordenadas
            $array[3] = ""

            dim $Colnames[4]

            $Colnames[0] = "Id_territorio"
            $Colnames[1] = "num_manzana"
            $Colnames[2] = "Coordenadas"
            $colnames[3] = ""



          _AddRecord($sql,'planos',$Colnames,$array)

          MsgBox(0,"","Manzana Ingresada")



         GUICtrlSetData($n_manzanas,Guictrlread($n_manzanas) + 1)
     EndIf

EndFunc

func _insert_Territorio()

    if GUICtrlRead($numero_territorio) = "" then
    MsgBox(0,"","Por Favor Ingrese un numero de Territorio")
    ElseIf GUICtrlRead($Nom_terr) = "" then
    MsgBox(0,"","Por Favor Ingrese el nombre del Territorio correpondiente")
    ElseIf GUICtrlRead($estado) = "" then
    MsgBox(0,"","Por Favor Ingrese Iniciales del Estado")
    ElseIf GUICtrlRead($ciudad1) = "" then
    MsgBox(0,"","Por Favor Ingrese el nombre de la ciudad")
    ElseIf GUICtrlRead($Barrio_terr) = "" then
    MsgBox(0,"","Por Favor Ingrese el Barrio Correspondiente")
    Else


        dim $array2[7]

            $array2[0] = GUICtrlRead($numero_territorio)
            $array2[1] = GUICtrlRead($Nom_terr)
            $array2[2] = GUICtrlRead($estado)
            $array2[3] = GUICtrlRead($ciudad1)
            $array2[4] = GUICtrlRead($Barrio_terr)
            $array2[5] = GUICtrlRead($n_manzanas)
            $array2[6] = ""



            dim $Colnames2[7]

            $Colnames2[0] = "N_territorio"
            $Colnames2[1] = "Nombre_territorio"
            $Colnames2[2] = "Estado"
            $colnames2[3] = "Ciudad"
            $colnames2[4] = "Barrio"
            $colnames2[5] = "Numero_Manzanas"
            $colnames2[6] = ""

        if MsgBox (36,"TerSys - Insertando Territorio...","¿Desea insertar El Territorio con el Numero Actual de Manzanas?") = 6 then

            _AddRecord($sql,'Territorios',$colnames2,$array2)


            Msgbox(0,"","Territorio Ingresado Correctamente")

             GUICtrlSetData($numero_territorio, "")
             GUICtrlSetData($Nom_terr, "")
             GUICtrlSetData($estado, "")
             GUICtrlSetData($ciudad1, "")
             GUICtrlSetData($Barrio_terr, "")
             GUICtrlSetData($n_manzanas, "1")

               Else

         EndIf


EndIf


EndFunc





Func _Screen_Shot()
    local $iid = FileFindFirstFile(@DesktopDir & "\Territorios\TempMap\*.*")
        _ScreenCapture_CaptureWnd(@DesktopDir & "\Territorios\TempMap\Gmap_" & $iid  & ".jpg",$Form1_1,10,32,537,472)
EndFunc



Func _Planos_Censo()


    local $i
    local $GetColVals = _GetcolVals($sql,"trabajo_territorio A inner join Planos B on (A.Manzanas_tr = B.num_manzana)","A.Manzanas_tr")

    local $ubound = _CountRecords($sql,"trabajo_territorio A inner join Planos B on (A.Manzanas_tr = B.num_manzana)", "B.coordenadas")


    for $i = 1 to $ubound

$query = _Query($sql,"select distinct B.coordenadas, " &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 105 ,'#ff0000', " &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 75 ,'#ff6347', " &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 45 ,'#ffa500','#00ff00'))) as line, " &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 105 ,'#ff0000' ," &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 75 ,'#ffa500' ," &@CRLF & _
"if (datediff(curdate(),A.data_1)  > 45 ,'#ffd700','#008000'))) as fill " & @CRLF & _
"from trabajo_territorio A inner join Planos B on (A.Manzanas_tr = B.num_manzana) and (A.territorio = B.id_territorio) where B.num_manzana = " & $GetColVals[$i])

            With $query
                $array1 = .fields("coordenadas").value
                $array2 = .fields("line").value
                $array3 = .fields("fill").value
            EndWith

if not IsArray($array1) or $array1= "" then

    MsgBox(0,"TerSys - Diseño de Territorio", "No Existen Territorios Diseñados, Por Favor diseñe Los Territorios" & @CRLF & _
            "En el mapa con el comando de diseño de mapas en la parte superior del Mapa de Google Maps")
    Else
        _GUICtrlGoogleMap_DrawPolygon($gmap,$array1,$array2,$array3)

    EndIf

    Next


EndFunc



func Ing_Tra_Terr()

    if GUICtrlRead($numero) = "" then
    MsgBox(0,"","Por Favor Ingrese un numero de Territorio")
    ElseIf GUICtrlRead($capitan) = "" then
    MsgBox(0,"","Por Favor Ingrese el nombre del capitán correpondiente")
    ElseIf GUICtrlRead($manzana) = "" then
    MsgBox(0,"","Por Favor Ingrese las manzanas trabajadas")

    Else
        $limits = StringInStr(GUICtrlRead($manzana),"-")
        If $limits  <> 0 Then

            local $numeros
            local $x = number(Stringmid(GUICtrlRead($manzana),$limits - 1,1))
            local $y = number(Stringmid(GUICtrlRead($manzana),$limits + 1,1))
            local $z = 1

           $numeros= ""
            for $x=number(Stringmid(GUICtrlRead($manzana),$limits - 1,1)) to $y
                _StringInsert($numeros,$numeros & ",",StringLen($numeros) +2)
        next

    MsgBox(0,"",$numeros)

            EndIf

        Dim $col8[5]

        $col8[0]= "data_1"
        $col8[1]= "Capitan"
        $col8[2]= "Territorio"
        $col8[3]= "Manzanas_tr"
        $col8[4]= ""

        Dim $val8[5]

        $val8[0]= _GUICtrlDate_Format(GUICtrlRead($Date3))
        $val8[1]= GUICtrlRead($capitan)
        $val8[2]= GUICtrlRead($numero)
        $val8[3]= GUICtrlRead($manzana)
        $val8[4]=""


        _AddRecord($sql,'trabajo_territorio',$col8, $val8)

            MsgBox(0,""," Datos Ingresados correctamente")

        GUICtrlSetData($Date3,"")
        GUICtrlSetData($numero,"")
        GUICtrlSetData($manzana,"")
        GUICtrlSetData($capitan,"")

    EndIf

EndFunc

Func _I_Excel($path)

    $oExcel=_ExcelBookOpen($path,0)
    $Ubound = 100

    for $i= 2 to $ubound

    Dim $Ex_Values[13]

    $Ex_Values[0]=_ExcelReadCell($oExcel,$i,1)
    $Ex_Values[1]=_ExcelReadCell($oExcel,$i,2)
    $Ex_Values[2]=_ExcelReadCell($oExcel,$i,3)
    $Ex_Values[3]=_ExcelReadCell($oExcel,$i,4)
    $Ex_Values[4]=_ExcelReadCell($oExcel,$i,5)
    $Ex_Values[5]=_ExcelReadCell($oExcel,$i,6)
    $Ex_Values[6]=_ExcelReadCell($oExcel,$i,7)
    $Ex_Values[7]=_ExcelReadCell($oExcel,$i,8)
    $Ex_Values[8]=_ExcelReadCell($oExcel,$i,9)
    $Ex_Values[9]=_ExcelReadCell($oExcel,$i,10)
    $Ex_Values[10]=_ExcelReadCell($oExcel,$i,11)
    $Ex_Values[11]=_ExcelReadCell($oExcel,$i,12)
    $Ex_Values[12]=""


    Dim $Ex_Colnames[13]

                $Ex_Colnames[0] = "Nombre_persona"
                $Ex_Colnames[1] = "Pais"
                $Ex_Colnames[2] = "Direccion"
                $Ex_Colnames[3] = "Numero"
                $Ex_Colnames[4] = "Tipo_de_vi"
                $Ex_Colnames[5] = "Ciudad"
                $Ex_Colnames[6] = "Barrio"
                $Ex_Colnames[7] = "Pub_asig"
                $Ex_Colnames[8] = "Tel"
                $Ex_Colnames[9] = "Email"
                $Ex_Colnames[10] = "Obs"
                $Ex_Colnames[11] = ""


     _AddRecord($sql,'personas', $Ex_Colnames,$Ex_Values)

next

if @error then
    MsgBox(0,"TerSys - Importacion de Archivos desde Base Excel", 'hola')
EndIf
    EndFunc

Func Insert_Coor_per()

    local $getcolvals = _GetcolVals($sql,"personas where coordenadas <> '' ", "codigo")
    local $counter =_CountRecords($sql,"personas where coordenadas <> ''","coordenadas")



    for $i= 1 to $counter

    local $query2 = _Query($sql, "select coordenadas from personas where coordenadas <> '' and codigo = " & $getcolvals[$i])
    with $query2
            local $Xcoord = .fields("coordenadas").value
        EndWith

_GUICtrlGoogleMap_AddMarkerByLatLng($gmap,$Xcoord)

Next

MsgBox(0,"TerSys - Ingreso de LatLng","GeoReferencias Insertadas")

EndFunc

Func Insert_Coor_per2()

    local $getcolvals = _GetColValsDistinct($sql,"personas where direccion <> '' and barrio <> '' and numero <> '' and ciudad <> ''","codigo")
    local $counter =_CountRecordsDistinct($sql," personas where direccion <> ''  and barrio <> '' and numero <> '' and ciudad <> ''","direccion")

    for $i= 1 to $counter

    local $query2 = _Query($sql,"select distinct direccion, numero, barrio, ciudad from personas where direccion <> '' and barrio <> '' " & _
    "and numero <> '' and ciudad <> '' and codigo = " & $getcolvals[$i])

    with $query2
            local $val1 = .fields("Direccion").value
            local $val2 = .fields("numero").value
            local $val3 = .fields("barrio").value
            local $val4 = .fields("ciudad").value
    EndWith

$getobtainvalue = $val1 & " " & $val2 & ", " & $val3 & ", " & $val4 & " - Espirito Santo, Brasil"

$icoord =_GUICtrlGoogleMap_GetLatLng($getobtainvalue)

_Query($sql,"UPDATE `personas` SET `coordenadas`='" & $icoord[0] & "," & $icoord[1] & "' WHERE CODIGO = '" & $getcolvals[$i] & "'")

Next

MsgBox(0,"TerSys - Ingreso de LatLng","GeoReferencias Insertadas")

EndFunc


Func Single_ter()

    if GUICtrlRead($Graficar_Single_input) = "" Then
        MsgBox(0,"TerSys - Graficar Territorios", "Porfavor , ingrese un numero de territorio a graficar")
    EndIf

    $nt = GUICtrlRead($Graficar_Single_input)

    local $UBound =_CountRecords($sql,"planos where id_territorio = " & $nt, "coordenadas")

For $i = 1 to $Ubound
    $ST=_Query ($sql,"Select Coordenadas from Planos where id_territorio = " & $nt & " And num_manzana = " & $i)

    with $ST
        $CTS= .fields("coordenadas").value
    endwith

    _GUICtrlGoogleMap_DrawPolygon($gmap,$CTS,'#000000','#000000')
Next

EndFunc

Func ing_fam()
    if $nfam ="" Then
        MsgBox(0, "TerSys - Ingreso Familia Publicadores","porfavor ingrese el nombre de la familia")
    ElseIf $Dirfam = "" Then
        Msgbox(0, "TerSys - Ingreso Familia Publicadores","porfavor ingrese una dirección" )
        Else

    Dim $famarray[4]

    $famarray[0] = GuiCtrlread($nfam)
    $famarray[1] = GuiCtrlread($telfam)
    $famarray[2] = GuiCtrlread($Dirfam)
    $famarray[3] =""

    Dim $colfam [4]

    $colfam[0] = "Nombre_familia"
    $colfam[1] = "Telefono"
    $colfam[2] = "Direccion"
    $colfam[3] = ""

    _AddRecord($sql,"fam_pub",$colfam,$famarray)

    MsgBox(0,"TerSys - ingreso Familia Publicadores","Familia Ingresada Correctamente")

    GUICtrlSetData($nfam,"")
    GUICtrlSetData($telfam,"")
    GUICtrlSetData($Dirfam,"")

EndIf

endfunc


Func _control_terr()

$on =_IECreateEmbedded()

   GUICtrlCreateObj($on,400,400)

    $route = "C:\Users\eduyfa bloqueado\Desktop\Reportes\control_territorio.html"
    $ieo =_IECreate()
    _IENavigate($ieo,$route)
    $table =_IETagNameGetCollection($ieo,"table")

_IEDocInsertHTML($table,"<tr id=""territorio"">" & @CRLF & _
"<td colspan=""2"" align=""center"">Territorio</td>" & @CRLF & _
"</tr>" & @CRLF & _
"</thead>" & @CRLF & _
"<tr>" & @CRLF & _
"<td colspan=""2"" align=""center"">" & "</td>" & @CRLF & _
"</tr>" & @CRLF & _
"<tr>" & @CRLF & _
"<td>fecha1</td>" & @CRLF & _
"<td>fecha2</td>" & @CRLF & _
"</tr>")

$ieo.document.body.scroll = "yes"

Return $ieo

GUISetState()


    EndFunc





;tratando de que funcione
Func Delete_planos()

_GUICtrlGoogleMap_HidePolygon($gmap)

EndFunc

 ;funcion interna
Func _GUICtrlDate_Format($date)

    $step1 = StringTrimLeft($date,6) & "/" & StringMid($date,4,2) & "/" & StringLeft($date,2)
    return $step1

EndFunc


Func RemoveStupidBlaklines($hwnd)
If Not IsHWnd($hwnd) Then Return
Local $pos=WinGetPos($hwnd,'')
If Not IsArray($pos) Then Return
Return WinMove($hwnd,'',$pos[0],$pos[1])
EndFunc

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  
Followers 0