FrmPesquisaCliente.frm
17.2 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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.2#0"; "MSCOMCTL.OCX"
Object = "{91488A85-7250-4842-8681-87818334B791}#1.0#0"; "NxViewManager2.ocx"
Begin VB.Form FrmPesquisaCliente
BorderStyle = 4 'Fixed ToolWindow
Caption = "Pesquisa"
ClientHeight = 4950
ClientLeft = 45
ClientTop = 315
ClientWidth = 8970
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4950
ScaleWidth = 8970
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin NxViewManager.ViewManager ViewManager1
Height = 375
Left = 6120
TabIndex = 8
Top = 4560
Width = 1215
_ExtentX = 2143
_ExtentY = 661
End
Begin VB.Frame Frame3
Caption = "Selecione para a Pesquisa"
Height = 975
Left = 30
TabIndex = 2
Top = 60
Width = 8895
Begin VB.CommandButton cmdPesquisa
Caption = "..."
Height = 285
Left = 8400
TabIndex = 5
Top = 480
Width = 345
End
Begin VB.ComboBox cboTipoFiltro
Height = 315
Left = 120
Style = 2 'Dropdown List
TabIndex = 4
Top = 480
Width = 3525
End
Begin VB.TextBox txtTextoFiltro
Height = 285
Left = 3780
TabIndex = 3
Top = 480
Width = 4515
End
Begin VB.Label Label2
Caption = "Digite a Informação"
Height = 255
Left = 3780
TabIndex = 7
Top = 240
Width = 1575
End
Begin VB.Label Label1
Caption = "Tipo de Filtro"
Height = 255
Left = 120
TabIndex = 6
Top = 240
Width = 1455
End
End
Begin VB.CommandButton cmdSair
Caption = "Sair"
Height = 345
Left = 7770
TabIndex = 1
Top = 4560
Width = 1155
End
Begin MSComctlLib.ListView lv
Height = 3375
Left = 60
TabIndex = 0
Top = 1110
Width = 8865
_ExtentX = 15637
_ExtentY = 5953
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
GridLines = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
End
Attribute VB_Name = "FrmPesquisaCliente"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private tcs As TeCanvas
Private cgeo As New clsGeoReference
Dim a As String
Dim b As String
Dim c As String
Dim d As String
Dim e As String
Dim f As String
Dim g As String
Dim h As String
Dim i As String
Dim j As String
Dim k As String
Dim l As String
Dim m As String
Public Function init(mtcs As TeCanvas) As Boolean
'LoozeXP1.InitIDESubClassing
With cboTipoFiltro
.AddItem "USUÁRIO - LOTES"
.AddItem "LOGRADOURO - LOTES"
.AddItem "CLASSIF. FISCAL - LOTES"
.AddItem "LIGACÕES PENDENTES - LOTES"
.AddItem "RAMAL ÁGUA"
.AddItem "LIGAÇÕES - RAMAL ÁGUA"
.AddItem "RAMAL ESGOTO"
.AddItem "LIGAÇÕES - RAMAL ESGOTO"
.AddItem "LOGRADOURO - NÓS DA REDE DE ÁGUA"
.ListIndex = 1
End With
txtTextoFiltro.Text = ""
Set tcs = mtcs
Me.Show vbModal
'LoozeXP1.EndWinXPCSubClassing
End Function
Private Sub cmdPesquisa_Click()
On Error GoTo cmdPesquisa_Click
Dim rs As ADODB.Recordset, str As String, rsA As ADODB.Recordset, cgeo As New clsGeoReference, LayerName As String
Dim a As Integer, itmx As ListItem
Screen.MousePointer = vbHourglass
With FrmMain
Select Case cboTipoFiltro.Text
Case "USUÁRIO - LOTES"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES)) Then
str = GetQueryProcess(7)
str = Replace(str, "@USUARIO", UCase(txtTextoFiltro.Text))
Set rs = ConnSec.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES), vbExclamation
Exit Sub
End If
Case "LOGRADOURO - LOTES"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES)) Then
str = GetQueryProcess(6)
str = Replace(str, "@LOGRADOURO", UCase(txtTextoFiltro.Text))
Set rs = ConnSec.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES), vbExclamation
Exit Sub
End If
Case "LOGRADOURO - NÓS DA REDE DE ÁGUA"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.Componente_Rede_Agua)) Then
str = GetQueryProcess(6)
str = Replace(str, "@LOGRADOURO", UCase(txtTextoFiltro.Text))
Set rs = ConnSec.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.Componente_Rede_Agua), vbExclamation
Exit Sub
End If
Case "CLASSIF. FISCAL - LOTES"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES)) Then
str = GetQueryProcess(9)
str = Replace(str, "@CLASSIFICACAO_FISCAL", txtTextoFiltro.Text)
Set rs = ConnSec.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES), vbExclamation
Exit Sub
End If
Case "LIGACÕES PENDENTES - LOTES"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES)) Then
Set rsA = New ADODB.Recordset
rsA.CursorType = adOpenDynamic
a = "NRO_LIGACAO"
b = cgeo.GetLayerOperation(tcs.getCurrentLayer, IIf(cgeo.GetLayerTypeReference(tcs.getCurrentLayer) = RAMAIS_AGUA, 1, 2))
c = b
d = "TIPO"
e = "HIDROMETRADO"
f = "ECONOMIAS"
g = "CONSUMO_LPS"
h = "TB_LIGACOES"
i = "HIDROMETRADO"
j = "ECONOMIAS"
k = "CONSUMO_LPS"
l = "TB_LIGACOES"
m = "_LIGACAO"
If frmCanvas.TipoConexao <> 4 Then
Set rsA = Conn.execute("SELECT NRO_LIGACAO FROM " & cgeo.GetLayerOperation(tcs.getCurrentLayer, IIf(cgeo.GetLayerTypeReference(tcs.getCurrentLayer) = RAMAIS_AGUA, 1, 2)) & "_LIGACAO")
Else
Set rsA = Conn.execute("SELECT " + """" + a + """" + " FROM + """" + c + m+ """" +")
End If
Set rs = ConnSec.execute(GetQueryProcess(17))
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.LOTES), vbExclamation
Exit Sub
End If
Case "RAMAL ÁGUA"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_AGUA)) Then
str = GetQueryProcess(12)
str = Replace(str, "@OBJECT_ID_", txtTextoFiltro.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Set rs = Conn.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_AGUA), vbExclamation
Exit Sub
End If
Case "RAMAL ESGOTO"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_ESGOTO)) Then
str = GetQueryProcess(12)
str = Replace(str, "@OBJECT_ID_", txtTextoFiltro.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Set rs = Conn.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_ESGOTO), vbExclamation
Exit Sub
End If
Case "LIGAÇÕES - RAMAL ÁGUA"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_AGUA)) Then
str = GetQueryProcess(13)
str = Replace(str, "@NRO_LIGACAO", txtTextoFiltro.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Set rs = Conn.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_AGUA), vbExclamation
Exit Sub
End If
Case "LIGAÇÕES - RAMAL ESGOTO"
If .ViewManager1.TvSetCurrentLayer(cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_ESGOTO)) Then
str = GetQueryProcess(13)
str = Replace(str, "@NRO_LIGACAO", txtTextoFiltro.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Set rs = Conn.execute(str)
Else
Screen.MousePointer = vbNormal
MsgBox "Não existe um tema relacionado ao plano: " & cgeo.GetLayerNameByTypeReference(LayerTypeRefence.RAMAIS_ESGOTO), vbExclamation
Exit Sub
End If
End Select
End With
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For a = 0 To rs.Fields.count - 1
lv.ColumnHeaders.Add , , UCase(rs.Fields(a).Name)
Next
If rsA Is Nothing Then Set rsA = New ADODB.Recordset
While Not rs.EOF
If rsA.State = 1 Then
rsA.Filter = "NRO_LIGACAO='" & rs.Fields("NRO_LIGACAO").value & "'"
If rsA.EOF Then
Set itmx = lv.ListItems.Add(, , IIf(IsNull(rs(0).value), "", UCase(rs(0).value)))
For a = 1 To rs.Fields.count - 1
itmx.SubItems(a) = IIf(IsNull(rs(a).value), "", UCase(rs(a).value))
Next
itmx.Tag = Left(rs.Fields(rs.Fields.count - 1).value, 11)
End If
Else
Set itmx = lv.ListItems.Add(, , IIf(IsNull(rs(0).value), "", UCase(rs(0).value)))
For a = 1 To rs.Fields.count - 1
itmx.SubItems(a) = IIf(IsNull(rs(a).value), "", UCase(rs(a).value))
Next
itmx.Tag = Left(rs.Fields(rs.Fields.count - 1).value, 11)
End If
rs.MoveNext
Wend
If rsA.State = 1 Then rs.Close
Set rsA = Nothing
If rs.State = 1 Then rs.Close
Set rs = Nothing
Screen.MousePointer = vbNormal
Exit Sub
cmdPesquisa_Click:
MsgBox "Ocorreu um erro no sistema, é possível que você não esteja no plano correto" & vbCrLf & Err.Description
Screen.MousePointer = vbNormal
End Sub
Private Sub cmdSair_Click()
Unload Me
End Sub
Private Sub lv_ItemClick(ByVal Item As MSComctlLib.ListItem)
On Error GoTo lv_ItemClick_err
Dim rs As ADODB.Recordset, object_id As String, xmin As Double, ymin As Double, xmax As Double, ymax As Double
Dim str As String
Select Case cboTipoFiltro
Case "USUÁRIO - LOTES", "LOGRADOURO - LOTES", "CLASSIF. FISCAL - LOTES", "LIGACÕES PENDENTES - LOTES"
str = GetQueryProcess(14)
str = Replace(str, "@CLASSIFICACAO_FISCAL", Item.SubItems(1))
Case "RAMAL ÁGUA", "LIGAÇÕES - RAMAL ÁGUA"
If cgeo.GetLayerTypeReference(tcs.getCurrentLayer) <> RAMAIS_AGUA Then
MsgBox "Selecione o plano/tema referente ao Ramal de Água", vbExclamation
End If
str = GetQueryProcess(16)
str = Replace(str, "@OBJECT_ID_", Item.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Case "RAMAL ESGOTO", "LIGAÇÕES - RAMAL ESGOTO"
If cgeo.GetLayerTypeReference(tcs.getCurrentLayer) <> RAMAIS_ESGOTO Then
MsgBox "Selecione o plano/tema referente ao Ramal de Esgoto", vbExclamation
Exit Sub
End If
str = GetQueryProcess(16)
str = Replace(str, "@CLASSIFICACAO_FISCAL", Item.Text)
str = Replace(str, "@LAYER", tcs.getCurrentLayer)
Case "LOGRADOURO - NÓS DA REDE DE ÁGUA"
str = GetQueryProcess(20)
str = Replace(str, "@CLASSIFICACAO_FISCAL", Item.SubItems(1))
End Select
With tcs
.Normal
Set rs = Conn.execute(str)
If Not rs.EOF Then
While Not rs.EOF
object_id = IIf(IsNull(rs!Object_id_), "", rs!Object_id_)
'If object_id <> "" Then
If .addSelectObjectIds(object_id) = 1 Then
.getSelectBox xmin, ymin, xmax, ymax
.setWorld xmin - 1000, ymin - 1000, xmax + 1000, ymax + 1000
.Select
.setScale 1000
Else
MsgBox "Não foi encontrado a geometria referente ao atributo selecionado", vbExclamation
End If
'Else
' MsgBox "Objecto não encontrado", vbExclamation
'End If
rs.MoveNext
Wend
Else
MsgBox "Número da inscrição não encontrado", vbExclamation
End If
rs.Close
Set rs = Nothing
End With
Exit Sub
lv_ItemClick_err:
MsgBox "Ocorreu um erro no sistema, é possível que você não esteja no plano correto" & vbCrLf & Err.Description
End Sub
' StrSql = "SELECT "
' StrSql = StrSql & " TL.tlogradnome AS TIPOVIA,"
' StrSql = StrSql & " L.logradnome AS LOGRADOURO,"
' StrSql = StrSql & " B.bairnome AS BAIRRO,"
' StrSql = StrSql & " I.imoburbcomplemento AS COMPLEMENTO,"
' StrSql = StrSql & " S.sannumerohidrometro AS NRO_HIDROMETRO,"
' StrSql = StrSql & " I.imoburbinscricao AS NRO_INSCRICAO"
' StrSql = StrSql & " FROM imobiliario_urbano I"
' StrSql = StrSql & " LEFT JOIN saneamento_imobiliario_urbano S ON S.imoburbcod=I.imoburbcod"
' StrSql = StrSql & " LEFT JOIN bairro B ON B.baircod=I.baircod"
' StrSql = StrSql & " LEFT JOIN logradouro L ON L.logradcod = I.logradcod"
' StrSql = StrSql & " LEFT JOIN tipo_logradouro TL ON TL.tlogradabreviatura = L.tlogradabreviatura"
' StrSql = StrSql & " WHERE L.logradnome LIKE '" & UCase(txtPesquisa.Text) & "%'"
' StrSql = "SELECT CO.contribnome AS CONTRIBUINTE,"
' StrSql = StrSql & " TL.tlogradnome AS TIPOVIA,"
' StrSql = StrSql & " L.logradnome AS LOGRADOURO,"
' StrSql = StrSql & " i.imoburbnumero as NUMERO,"
' StrSql = StrSql & " B.bairnome AS BAIRRO,"
' StrSql = StrSql & " I.imoburbcomplemento AS COMPLEMENTO,"
' StrSql = StrSql & " S.sannumerohidrometro AS NRO_HIDROMETRO,"
' StrSql = StrSql & " I.imoburbinscricao AS NRO_INSCRICAO"
' StrSql = StrSql & " FROM contribuinte CO"
' StrSql = StrSql & " INNER JOIN socio_imobiliario_urbano SO ON SO.contribcodsocio=CO.contribcod"
' StrSql = StrSql & " LEFT JOIN imobiliario_urbano I ON I.imoburbcod=SO.imoburbcod"
' StrSql = StrSql & " LEFT JOIN saneamento_imobiliario_urbano S ON S.imoburbcod=I.imoburbcod"
' StrSql = StrSql & " LEFT JOIN bairro B ON B.baircod=I.baircod"
' StrSql = StrSql & " LEFT JOIN logradouro L ON L.logradcod = I.logradcod"
' StrSql = StrSql & " LEFT JOIN tipo_logradouro TL ON TL.tlogradabreviatura = L.tlogradabreviatura"
' StrSql = StrSql & " WHERE CO.contribnome LIKE '" & UCase(txtPesquisa.Text) & "%'"
' StrSql = StrSql & " ORDER BY CO.contribnome,L.logradnome,i.imoburbnumero"
' StrSql = "SELECT "
' StrSql = StrSql & " TL.tlogradnome AS TIPOVIA,"
' StrSql = StrSql & " L.logradnome AS LOGRADOURO,"
' StrSql = StrSql & " B.bairnome AS BAIRRO,"
' StrSql = StrSql & " I.imoburbcomplemento AS COMPLEMENTO,"
' StrSql = StrSql & " S.sannumerohidrometro AS NRO_HIDROMETRO,"
' StrSql = StrSql & " I.imoburbinscricao AS NRO_INSCRICAO"
' StrSql = StrSql & " FROM imobiliario_urbano I"
' StrSql = StrSql & " LEFT JOIN saneamento_imobiliario_urbano S ON S.imoburbcod=I.imoburbcod"
' StrSql = StrSql & " LEFT JOIN bairro B ON B.baircod=I.baircod"
' StrSql = StrSql & " LEFT JOIN logradouro L ON L.logradcod = I.logradcod"
' StrSql = StrSql & " LEFT JOIN tipo_logradouro TL ON TL.tlogradabreviatura = L.tlogradabreviatura"
' StrSql = StrSql & " WHERE I.imoburbinscricao LIKE '" & UCase(txtPesquisa.Text) & "%'"
Private Sub txtTextoFiltro_Change()
End Sub