Sign in to follow this  
Followers 0
ookythemurder

Making a Database program

2 posts in this topic

I'm newbiee and i'm trying to make a database program for my bussiness.

The database is fully managed with csv files...i'm crazy...yes i know...but i can't make works Mysql or sqllite...in some years maybe... <_<

Ok....what's the matter....the program in the main loop works well...but when i call a function named NuevaEmpresa() buttons don't work. I proved all...but not response

Another question by the way is how can i close the second window i opened with not exit the program? i don't know the function

I will put the code down this.

Sorry by my horrible english...i hope you understand me.

#include <Array.au3>
#include <Date.au3>
#include <GuiConstants.au3>
#include <IE.au3>
_IEErrorHandlerRegister ()
$oIE = _IECreateEmbedded ()

HotKeySet("{ESC}", "Terminate")
Global $line , $i, $linearray[12], $linearray2[7], $j


$Form1 = GUICreate("Base de Datos",@DesktopWidth,@DesktopHeight-30, 0, 0)
GUISetCursor (2)
GUISetBkColor(0xC0DCC0)
$Group1 = GUICtrlCreateGroup("Empresas", 16, 112, 225, 441)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$List1 = GUICtrlCreateList("", 32, 128, 185, 409)
$Group3 = GUICtrlCreateGroup("Acción", 120, 32, 569, 57)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
$Button5 = GUICtrlCreateButton("Histórico", 568, 48, 113, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Información de Empresa", 264, 112, 297, 209)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
$List2 = GUICtrlCreateList("", 272, 128, 281, 175,1)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Actualizar", 160, 112, 81, 17, 0)
$Button2 = GUICtrlCreateButton("Añadir Empresa", 128, 48, 129, 33, 0)
$Button3 = GUICtrlCreateButton("Modificar Empresa", 280, 48, 121, 33, 0)
$Button4 = GUICtrlCreateButton("Acción Comercial", 424, 48, 121, 33, 0)
$Button6 = GUICtrlCreateButton("->", 243, 180, 20, 17, 0)
$Group4 = GUICtrlCreateGroup("Histórico Acciones Comerciales", 576, 112, 700, 441)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
$List3 = GUICtrlCreateList("", 592, 128, 670, 409,1)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$MonthCal1 = GUICtrlCreateMonthCal(@year/@MON/@MDAY, 272, 360, 282, 169)
$GUIActiveX = GUICtrlCreateObj($oIE,10, 560, 1260, 160)
GUISetState(@SW_SHOW)
_IENavigate ($oIE, "http://es.news.search.yahoo.com/search/news?ei=UTF-8&p=innovacion&meta=vl%3D&fr2=tab-web&fr=yfp-t-501")
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button1
        $i = $i+1
        LeerEmpresas()
    Case $msg = $Button2
        NuevaEmpresa()
    Case $msg = $Button5
        $j = GUICtrlRead($List1)
        
        CaptarHistoricoEmpresa($j)
    Case $msg = $Button6
        
        
        $j = GUICtrlRead($List1)
        
        CaptarInfoEmpresa($j)
        
    Case Else
    ;;;
    EndSelect

WEnd
Exit
#endregion --- GuiBuilder generated code End ---

Func Terminate()
;when escape is hit, stop.
    MsgBox(0, "", "Programa Interrumpido Manualmente")

EndFunc ;==>Terminate

Func Leerempresas()
    $file = FileOpen("c:\program files\baseempresas\empresas.csv", 0)
    While $i > 0
    
        If $i = 100 Then
            ExitLoop
        EndIf
        $line = FileReadLine($file,$i)
        If @error = -1 Then
            ExitLoop
        EndIf
        $linearray = StringSplit($line, ";")
        GUICtrlSetData($List1, $linearray[2])
        $i = $i +1
        
    WEnd    
FileClose($file)
EndFunc;== Leerempresas

Func CaptarInfoEmpresa($j)
    $file = FileOpen("c:\program files\baseempresas\empresas.csv", 0)
    $i= 1
    While $i > 0
    
        If $i = 100 Then
            ExitLoop
        EndIf
        $line = FileReadLine($file,$i)
        If @error = -1 Then
            ExitLoop
        EndIf
        $linearray = StringSplit($line, ";")
        if $linearray[2] = $j Then
            ExitLoop
        EndIf
        
        $i = $i +1
        
    WEnd
        $contador = 2
        GUICtrlsetdata($list2, "",1)
    while $contador > 0
    
        
        GUICtrlSetData($List2, $linearray[$contador])
        $contador= $contador +1
        
        if $contador = 13 Then
            ExitLoop
        EndIf
    WEnd
_IENavigate ($oIE, $linearray[4])
FileClose($file)
EndFunc

Func CaptarHistoricoEmpresa($j)
    $file = FileOpen("c:\program files\baseempresas\accionescomerciales.csv", 0)
    $i= 1
    $z = 0
    GUICtrlsetdata($list3, "",1)
    while $i > 0
        While $i > 0
        
            If $i = 100 Then
                ExitLoop
            EndIf
            $line = FileReadLine($file,$i)
            If @error = -1 Then
                
                $z =1
                ExitLoop
            EndIf
            $linearray2 = StringSplit($line, ";")
            if $linearray2[2] = $j Then
                ExitLoop
            EndIf
            
            $i = $i +1
            
        WEnd
            $contador = 2
        ;GUICtrlsetdata($list3, "",1)
        while $contador > 0
        
            if $z = 1 Then
                GUICtrlSetData($List3, "NO EXISTEN DATOS")
                ExitLoop
            EndIf
            GUICtrlSetData($List3, $linearray2[$contador])
            $contador= $contador +1
            
            if $contador = 8 Then
                ExitLoop
            EndIf
        WEnd
        GUICtrlSetData($List3, "------------------------------------------------------------------------------------------------------------")
        $i= $i +1
        if $z = 1 Then
                GUICtrlSetData($List3, "NO EXISTEN DATOS")
                ExitLoop
            EndIf
    WEnd
FileClose($file)
EndFunc 

Func NuevaEmpresa()

    $Form2 = GUICreate("AForm2", 769, 384, 193, 115)
    $Group1 = GUICtrlCreateGroup("NUEVA EMPRESA", 16, 16, 737, 353)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Group2 = GUICtrlCreateGroup("Nombre", 48, 48, 249, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input1 = GUICtrlCreateInput("", 64, 64, 217, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group3 = GUICtrlCreateGroup("Teléfono", 48, 112, 249, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input2 = GUICtrlCreateInput("", 64, 128, 217, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group4 = GUICtrlCreateGroup("Página Web", 48, 176, 249, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input3 = GUICtrlCreateInput("", 64, 192, 217, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group5 = GUICtrlCreateGroup("Fecha Ficha", 48, 240, 249, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Date1 = GUICtrlCreateDate("", 64, 256, 217, 21)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group6 = GUICtrlCreateGroup("Persona Contacto", 48, 304, 249, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input4 = GUICtrlCreateInput("", 64, 320, 217, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group7 = GUICtrlCreateGroup("Puesto", 336, 48, 225, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Combo1 = GUICtrlCreateCombo("", 352, 64, 193, 25)
    GUICtrlSetData(-1, "Director Financiero|Secretaria|Director Comercial|Gerente|Responsable Fábrica|Responsable de Planta|Director de Marketing")
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group8 = GUICtrlCreateGroup("e-mail", 336, 112, 225, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input5 = GUICtrlCreateInput("", 352, 128, 193, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group9 = GUICtrlCreateGroup("Población", 336, 176, 225, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input6 =GUICtrlCreateInput("", 352, 192, 193, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group10 = GUICtrlCreateGroup("Sector", 336, 240, 225, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input7 = GUICtrlCreateInput("", 352, 256, 193, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group11 = GUICtrlCreateGroup("Empresa que realiza el Outsorcing", 336, 304, 225, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input8 = GUICtrlCreateInput("", 352, 320, 193, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Group12 = GUICtrlCreateGroup("Teléfono directo", 600, 48, 150, 49)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0x0A246A)
    $Input9 = GUICtrlCreateInput("", 610, 64, 125, 21)
    GUICtrlSetColor(-1, 0x0A246A)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Button7 = GUICtrlCreateButton("AÑADIR EMPRESA", 592, 312, 137, 41, 0)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)


    While 1
        $msg = GUIGetMsg()
        MsgBox(0,"jeje", "entra en while"); Event watch
        Select
            Case $GUI_EVENT_CLOSE
                
                Exitloop
            Case $msg = $Button7
                MsgBox(0,"jeje", "entrando en case");event watch
                While 1
                    $i = 1
                    $file = FileOpen("c:\program files\baseempresas\empresas.csv", 0)
                    $line = FileReadLine($file, $i)
                    If @error = -1 Then
                        FileClose($file)
                        Exitloop            
                    EndIf
                    $i = $i +1
                WEnd
                MsgBox(0,"jeje", "finalizando while" & $i);Event watch
                $file = FileOpen("c:\program files\baseempresas\empresas.csv", 1)
                $linearray[1] = $i
                $linearray[2] = GUICtrlRead($Input1)
                $linearray[3] = GUICtrlRead($Input2)
                $linearray[4] = GUICtrlRead($Input3)
                $linearray[5] = GUICtrlRead($Date1)
                $linearray[6] = GUICtrlRead($Input4)
                $linearray[7] = GUICtrlRead($Combo1)
                $linearray[8] = GUICtrlRead($Input9)
                $linearray[9] = GUICtrlRead($Input5)
                $linearray[10] = GUICtrlRead($Input6)
                $linearray[11] = GUICtrlRead($Input7)
                $linearray[12] = GUICtrlRead($Input8)
                FileWrite($file, $linearray[1] & ";" & $linearray[2] & ";" & $linearray[3] & ";" & $linearray[4] & ";" & $linearray[5] & ";" & $linearray[6] & ";" & $linearray[7] & ";" & $linearray[8] & ";" & $linearray[9] & ";" & $linearray[10] & ";" & $linearray[11] & ";" & $linearray[12])
                FileClose($file)
                ExitLoop
            Case Else
        EndSelect

    WEnd
EndFunc

Share this post


Link to post
Share on other sites



Solved...i found the solution. <_<

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