frmCadastroRamalAutoLote.frm 11.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
VERSION 5.00
Begin VB.Form frmCadastroRamalAutoLote 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Campos de Pesquisa por Lotes"
   ClientHeight    =   4440
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5835
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4440
   ScaleWidth      =   5835
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.ComboBox cboTabelaAtributos 
      Height          =   315
      Left            =   150
      Sorted          =   -1  'True
      TabIndex        =   8
      Top             =   1455
      Width           =   2325
   End
   Begin VB.CommandButton cmdCancelar 
      Caption         =   "Cancelar"
      Height          =   405
      Left            =   3705
      TabIndex        =   7
      Top             =   3900
      Width           =   975
   End
   Begin VB.CommandButton cmdSalvar 
      Caption         =   "Salvar"
      Enabled         =   0   'False
      Height          =   405
      Left            =   4725
      TabIndex        =   6
      Top             =   3900
      Width           =   975
   End
   Begin VB.ComboBox cboCampoNroLigacao 
      Height          =   315
      Left            =   150
      Sorted          =   -1  'True
      TabIndex        =   2
      Top             =   3120
      Width           =   2325
   End
   Begin VB.ComboBox cboCampoIPTU 
      Height          =   315
      Left            =   150
      Sorted          =   -1  'True
      TabIndex        =   1
      Top             =   2250
      Width           =   2325
   End
   Begin VB.ComboBox cboTemaLotes 
      Height          =   315
      Left            =   150
      TabIndex        =   0
      Top             =   630
      Width           =   2325
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "Selecione a tabela de Atributos do plano de Lotes"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   150
      TabIndex        =   9
      Top             =   1140
      Width           =   4470
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "Selecione a coluna referente a informação Número Ligação"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   150
      TabIndex        =   5
      Top             =   2805
      Width           =   5325
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Selecione a coluna referente a informação IPTU"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   150
      TabIndex        =   4
      Top             =   1920
      Width           =   4290
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Selecione o tema referente ao plano de Lotes"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   150
      TabIndex        =   3
      Top             =   315
      Width           =   4080
   End
End
Attribute VB_Name = "frmCadastroRamalAutoLote"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim contVetor As Integer
Dim rs As ADODB.Recordset
Dim blnIPTU As Boolean
Dim TbAtributos As String
Dim ve As String
         Dim vi As String
         Dim vo As String
         Dim vu As String
         Dim vc As String
          Dim vd As String
          Dim vm As String
          Dim vf As String




Private Sub cmdCancelar_Click()
   Unload Me
 
End Sub

Private Sub cmdSalvar_Click()

   'GRAVA NO ARQUIVO INI AS CONFIGURAÇÕES DE PESQUISA
   
   Call WriteINI("RAMAISFILTROLOTES", "TABELA_PLANO", Me.cboTemaLotes.Text, App.path & "\CONTROLES\GEOSAN.INI")
   Call WriteINI("RAMAISFILTROLOTES", "TABELA_ATRIB", Me.cboTabelaAtributos.Text, App.path & "\CONTROLES\GEOSAN.INI")
   Call WriteINI("RAMAISFILTROLOTES", "REF_IPTU", Me.cboCampoIPTU.Text, App.path & "\CONTROLES\GEOSAN.INI")
   Call WriteINI("RAMAISFILTROLOTES", "REF_NROLIGACAO", Me.cboCampoNroLigacao.Text, App.path & "\CONTROLES\GEOSAN.INI")


   Unload Me

End Sub

Private Sub Form_Load()
    
   Dim str As String
   
   Close #3
   
   Open glo.diretorioGeoSan + "\CONTROLES\FTema.txt" For Input As #3    'LÊ O ARQUIVO LOG QUE FOI CRIADO NO MOMENTO DE ABERTURA DO MAPA
   Do While Not EOF(3)
      Line Input #3, str
      Vetor = Split(str, ";")
      Me.cboTemaLotes.AddItem Vetor(1)
   Loop
   Close #3
    
   Set rs = New ADODB.Recordset
   va = "TABLES"
         ve = "OBJECT_ID_"
         vi = "NRO_LIGACAO"
         vo = "INSCRICAO_LOTE"
         vu = "TIPO"
         vc = "HIDROMETRADO"
         vd = "NXGS_V_LIG_COMERCIAL"
         ve = "CONSUMO_LPS"
         vf = "ECONOMIAS"
         
             If frmCanvas.TipoConexao = 1 Then
   str = "SELECT NAME AS TABELA FROM SYS.TABLES"
    
   ElseIf frmCanvas.TipoConexao = 2 Then
      str = "SELECT DISTINCT TABLE_NAME AS " + """" + "TABELA" + """" + " FROM ALL_TAB_COLS"
   
  
   ElseIf frmCanvas.TipoConexao = 4 Then
    Dim ad As String
   Dim ae As String
   ad = "NAME"
   ae = "pg_tables"
     str = "SELECT" + """" + "tablename" + """" + "As" + """" + "TABELA" + """" + " FROM " + """" + ae + """"
     End If
     
      rs.Open str, Conn, adOpenDynamic, adLockOptimistic
   
   Do While Not rs.EOF
      Me.cboTabelaAtributos.AddItem rs!TABELA
      rs.MoveNext
   Loop
   rs.Close
    
   Me.cboTemaLotes.Text = ReadINI("RAMAISFILTROLOTES", "TABELA_PLANO", App.path & "\CONTROLES\GEOSAN.INI")
   Me.cboTabelaAtributos.Text = ReadINI("RAMAISFILTROLOTES", "TABELA_ATRIB", App.path & "\CONTROLES\GEOSAN.INI")
   Me.cboCampoIPTU.Text = ReadINI("RAMAISFILTROLOTES", "REF_IPTU", App.path & "\CONTROLES\GEOSAN.INI")
   Me.cboCampoNroLigacao.Text = ReadINI("RAMAISFILTROLOTES", "REF_NROLIGACAO", App.path & "\CONTROLES\GEOSAN.INI")

    
End Sub
Private Sub ValidaTema()
   'CAPTURAR O NOME DE TODAS AS COLUNAS DA TABELA
   
   Dim strsql As String
   Dim codTema As Integer
   Dim str As String
   
   Me.cboCampoIPTU.Clear
   Me.cboCampoNroLigacao.Clear

   Set rs = New ADODB.Recordset
   
   'PROCURAR NO VETOR O ID DO TEMA SELECIONADO
   Close #3
   Open glo.diretorioGeoSan + "\GEOSAN\CONTROLES\FTema.txt" For Input As #3     'LÊ O ARQUIVO LOG QUE FOI CRIADO NO MOMENTO DE ABERTURA DO MAPA
   Do While Not EOF(3)
       Line Input #3, str
       Vetor = Split(str, ";")
       If CStr(Vetor(1)) = CStr(Me.cboTemaLotes.Text) Then
           codTema = Vetor(0)
           Exit Do
       End If
   Loop
   Close #3
   
   Dim LayNome As String
   If frmCanvas.TipoConexao <> 4 Then
   
   'VERIFICA SE O TEMA SELECIONADO POSSUI A GEOMETRIA DE POLIGONOS
   strsql = "SELECT * FROM TE_REPRESENTATION WHERE GEOM_TYPE = 1 AND LAYER_ID = (SELECT LAYER_ID FROM TE_THEME WHERE THEME_ID = " & codTema & ")"
   Set rs = New ADODB.Recordset
   rs.Open strsql, Conn, adOpenForwardOnly, adLockReadOnly
   
   If rs.EOF = True Then
      'NÃO FOI LOCALIZADO A GEOMETRIA DE POLÍGONOS NO PLANO SELECIONADO
      MsgBox "O tema selecionado não possui polígonos.", vbInformation, ""
      rs.Close
      'Exit Sub
   End If
   Else
   Dim ff As String
   Dim fd As String
   Dim fc As String
   Dim fb As String
   Dim fg As String
   ff = "te_representation"
   fd = "geom_type"
   fc = "layer_id"
   fb = "te_theme"
   fg = "theme_id"
   
   
   strsql = "SELECT * FROM " + """" + ff + """" + " WHERE " + """" + fd + """" + " = '1' AND " + """" + fc + """" + " = (SELECT " + """" + fc + """" + " FROM " + """" + fb + """" + " WHERE " + """" + fg + """" + " = '" & codTema & "')"
   End If
   Set rs = New ADODB.Recordset
    rs.Open strsql, Conn, adOpenDynamic, adLockOptimistic
   
   If rs.EOF = True Then
      'NÃO FOI LOCALIZADO A GEOMETRIA DE POLÍGONOS NO PLANO SELECIONADO
      MsgBox "O tema selecionado não possui polígonos.", vbInformation, ""
      rs.Close
      'Exit Sub
   End If
   
End Sub


Private Sub CARREGA_COMBOS()


   
'   'LOCALIZA A TABELA DE ATRIBUTOS DO PLANO
'   strsql = "SELECT ATTR_TABLE FROM TE_LAYER_TABLE WHERE LAYER_ID = (SELECT LAYER_ID FROM TE_THEME WHERE THEME_ID = " & codTema & ")"
'   Set RS = New ADODB.Recordset
'   RS.Open strsql, Conn, adOpenForwardOnly, adLockReadOnly
'
'   If RS.EOF = False Then
'      TbAtributos = RS!ATTR_TABLE
'   Else
'      MsgBox "Não foi localizada a tabela de atributos do tema. (TE_LAYER_TABLE) " & Chr(13) & Chr(13) & "Será utilizado os campos da própria tabela.", vbInformation, ""
'      TbAtributos = Me.cboTemaLotes.Text
'      RS.Close
'      'Exit Sub
'   End If

   
   'CARREGA NOS COMBOS IPTU E NRO_LIGACAO OS NOMES DAS COLUNAS DA TABELA DE ATRIBUTOS
   va = "RAMAIS_AGUA_LIGACAO"
         ve = "OBJECT_ID_"
         vi = "NRO_LIGACAO"
         vo = "INSCRICAO_LOTE"
         vu = "TIPO"
         vc = "HIDROMETRADO"
         vd = "NXGS_V_LIG_COMERCIAL"
         vm = "CONSUMO_LPS"
         vf = "ECONOMIAS"
         
             If frmCanvas.TipoConexao <> 4 Then
   strsql = "SELECT * FROM " & Me.cboTabelaAtributos.Text
   Else
      strsql = "SELECT * FROM " + """" + Me.cboTabelaAtributos.Text + """"
   
   End If
   
   
   Set rs = New ADODB.Recordset
     rs.Open strsql, Conn, adOpenDynamic, adLockOptimistic
   
   Me.cboCampoIPTU.Clear
   Me.cboCampoNroLigacao.Clear

   
  ' If rs.EOF = False Then
     
      For i = 0 To rs.Fields.count - 1
         Me.cboCampoIPTU.AddItem rs.Fields(i).Name 'NOME DA COLUNA
         Me.cboCampoNroLigacao.AddItem rs.Fields(i).Name 'NOME DA COLUNA
      Next
   
  ' End If
   
   rs.Close

End Sub

Private Sub cboTemaLotes_Click()
   If Me.cboTemaLotes.Text <> "" Then
      ValidaTema
   End If
End Sub

'Private Sub cboTemaLotes_LostFocus()
'   If Me.cboTemaLotes.Text <> "" Then
'      ValidaTema
'   End If
'End Sub
'
'Private Sub cboTabelaAtributos_LostFocus()
'   If Me.cboTabelaAtributos.Text <> "" Then
'      CARREGA_COMBOS
'   End If
'End Sub

Private Sub cboTabelaAtributos_click()
   If Me.cboTabelaAtributos.Text <> "" Then
      CARREGA_COMBOS
   End If
End Sub

Private Sub cboCampoIPTU_Click()
   
   If VerificaSeNumerico(Me.cboCampoIPTU.Text, Me.cboTabelaAtributos.Text) = True Then
      blnIPTU = True
   Else
      blnIPTU = False
      Me.cmdSalvar.Enabled = False
      MsgBox "O campo selecionado possui registro não numérico ou vazio e não pode ser utilizado.", vbInformation, ""
   End If
   
End Sub

Private Sub cboCampoNroLigacao_Click()
  
   If VerificaSeNumerico(Me.cboCampoNroLigacao.Text, Me.cboTabelaAtributos.Text) = True Then
      If blnIPTU = True Then
         Me.cmdSalvar.Enabled = True
      End If
   Else
      Me.cmdSalvar.Enabled = False
      MsgBox "O campo selecionado possui registro não numérico ou vazio e não pode ser utilizado.", vbInformation, ""
   End If

End Sub