frmImportFile.frm
10.6 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
VERSION 5.00
Object = "{87AC6DA5-272D-40EB-B60A-F83246B1B8D7}#1.0#0"; "TECOMD~1.DLL"
Object = "{2CCABA93-B681-4E7F-8047-BD4D623301BA}#1.0#0"; "TECOMI~1.DLL"
Object = "{9AB389E7-EAED-4DBF-941D-EB86ED1F9A76}#1.0#0"; "TECOMC~1.DLL"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmImportFile
BorderStyle = 4 'Fixed ToolWindow
Caption = "Importar "
ClientHeight = 2130
ClientLeft = 45
ClientTop = 345
ClientWidth = 4350
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2130
ScaleWidth = 4350
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame
Height = 2175
Index = 0
Left = 30
TabIndex = 0
Top = -60
Width = 4305
Begin TECOMIMPORTLibCtl.TeImport TeImport1
Left = 3120
OleObjectBlob = "frmImportFile.frx":0000
Top = 240
End
Begin MSComDlg.CommonDialog cdl
Left = 1770
Top = 1590
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton cmdImport
Caption = "Importar"
Height = 375
Left = 420
TabIndex = 7
Top = 1560
Width = 1095
End
Begin VB.CommandButton cmdCancel
Caption = "Cancelar"
Height = 375
Left = 2730
TabIndex = 6
Top = 1560
Width = 1095
End
Begin VB.ComboBox cboLayer
Height = 315
ItemData = "frmImportFile.frx":0024
Left = 360
List = "frmImportFile.frx":0026
TabIndex = 5
Top = 450
Width = 3525
End
Begin VB.TextBox txtFileName
Height = 285
Left = 360
Locked = -1 'True
TabIndex = 2
Top = 1020
Width = 3165
End
Begin VB.CommandButton cmdOpenFile
Caption = "...."
Height = 285
Left = 3570
TabIndex = 1
Top = 1020
Width = 285
End
Begin TeComConnectionLibCtl.TeAcXConnection TeAcXConnection1
Left = 3840
OleObjectBlob = "frmImportFile.frx":0028
Top = 840
End
Begin TECOMDATABASELibCtl.TeDatabase TeDatabase1
Left = 3840
OleObjectBlob = "frmImportFile.frx":004C
Top = 360
End
Begin VB.Label lblLayer
AutoSize = -1 'True
Caption = "Plano de Informação"
Height = 195
Left = 360
TabIndex = 4
Top = 210
Width = 1470
End
Begin VB.Label Label1
Caption = "Nome do Arquivo"
Height = 225
Left = 360
TabIndex = 3
Top = 810
Width = 1275
End
End
End
Attribute VB_Name = "frmImportFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Mylayer As String
Private Conn As ADODB.connection
Dim tdb As TeDatabase
Dim TeImp As TeImport
Dim aa 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 mPROVEDOR As String
Dim mSERVIDOR As String
Dim mPORTA As String
Dim mBANCO As String
Dim mUSUARIO As String
Dim Senha As String
Dim decriptada As String
Dim Abertura As Integer
'Public Function init(mConn As ADODB.Connection, tImp As TeImport, mtdb As TeDatabase) As String
' 'LoozeXP1.InitIDESubClassing
' Set Conn = mConn
' Set TeImp = tImp
' Set tdb = mtdb
' Me.Show vbModal
' init = Mylayer
' 'LoozeXP1.EndWinXPCSubClassing
'End Function
Public Function init(mConn As ADODB.connection, ti As TeImport, td As TeDatabase) As String
'LoozeXP1.InitIDESubClassing
Set Conn = mConn
Set tdb = td
Set TeImp = ti
Me.Show vbModal
init = Mylayer
'LoozeXP1.EndWinXPCSubClassing
End Function
Private Sub cmdCancel_Click()
Me.Hide
End Sub
Private Sub cmdImport_Click()
'On Error GoTo Trata_Erro
Dim result As Integer, a As Integer, IniciouTransacao As Boolean
Dim rs As New ADODB.Recordset
Dim SQL As String
Dim dy As String
Dim dh As String
dy = "te_layer"
dh = "name"
IniciouTransacao = True
Dim a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 As String
If cboLayer.Text = "" Then
MsgBox "O campo nome do plano esta vazio !", vbInformation
Exit Sub
End If
If txtFileName.Text = "" Then
MsgBox "O campo nome do arquivo está vazio!", vbInformation
Exit Sub
End If
If frmCanvas.TipoConexao <> 4 Then
SQL = "SELECT * FROM TE_LAYER WHERE Name = '" & UCase(cboLayer.Text) & "'"
Else
SQL = "SELECT * FROM " + """" + dy + """" + " WHERE " + """" + dh + """" + " = '" & cboLayer.Text & "'"
End If
rs.Open SQL, Conn, adOpenDynamic, adLockOptimistic
If Not rs.EOF Then
rs.Close
MsgBox "Plano já existe", vbExclamation
Exit Sub
Else
rs.Close
If frmProjection.init() Then
'CRIA O NOVO LAYER ''ATENÇÃO! TUDO EM CASE SENSITIVE!!
'cboLayer.Text = "teste_teste"
' Set TeImp = TeImport1
'Set tdb = TeDatabase1
a1 = UCase(cboLayer.Text)
a2 = UCase(frmProjection.cboProjecao)
a3 = UCase(frmProjection.cboDatum)
a4 = UCase(frmProjection.txtLongOrigem)
a5 = UCase(frmProjection.txtLatOrigem)
a6 = UCase(frmProjection.txtOffSetX)
a7 = UCase(frmProjection.txtOffSetY)
a8 = UCase(frmProjection.txtParPadrao1)
a9 = UCase(frmProjection.txtParPadrao2)
If TeImp.createLayer(a1, a2, a3, a4, a5, a6, a7, a8, a9, 2) = True Then
End If
' If TeImp.createLayer(a1, a2, a3, a4, a5, a6, a7, a8, a9, 2) = True Then
' End If
'If TeImp.createLayer("hhhyuzzt55hh", "UTM", "SAD69", "-45", "0", "50000", "1000000", "0", "0", 2) = True Then
' End If
'ADICIONA AS GEOMETRIAS
tdb.addGeometryRepresentation UCase(cboLayer.Text), 1 'poligono
tdb.addGeometryRepresentation UCase(cboLayer.Text), 4 'pontos
tdb.addGeometryRepresentation UCase(cboLayer.Text), 128 'textos
Else
Exit Sub
End If
Screen.MousePointer = vbHourglass
Select Case UCase(Right(txtFileName.Text, 3))
Case "GEO":
result = TeImp.importGeoTab(txtFileName.Text, cboLayer.Text, "")
Case "SHP":
result = TeImp.importSHP(txtFileName.Text, cboLayer.Text, "")
Case "MIF":
result = TeImp.importMIF(txtFileName.Text, cboLayer.Text, "", "")
End Select
Screen.MousePointer = vbNormal
If result = 1 Then
Mylayer = cboLayer.Text
If frmCanvas.TipoConexao <> 4 Then
Conn.execute "INSERT INTO X_LayersComponents (LAYERLINE,LAYERCOMPONENT,TYPEREFERENCE,TYPETEXT) VALUES('" & Mylayer & "','" & Mylayer & "',4,1)"
Else
aa = "LAYERLINE"
b = "LAYERCOMPONENT"
c = "TYPEREFERENCE"
d = "TYPETEXT"
h = "X_LAYERSCOMPONENTS"
Conn.execute "INSERT INTO " + """" + h + """" + " ( " + """" + aa + """" + " ," + """" + b + """" + "," + """" + c + """" + "," + """" + d + """" + " ) VALUES('" & Mylayer & "','" & Mylayer & "','4','1')"
End If
Set rs = Conn.execute("SELECT * from " & cboLayer.Text)
For a = 0 To rs.Fields.count - 1
If frmCanvas.TipoConexao <> 4 Then
Conn.execute "Insert into X_ManagerPropertiesB (TableName,FieldSequence) values('" & cboLayer.Text & "'," & a & ")"
Else
aa = "TABLENAME"
b = "FIELDSEQUENCE"
h = "X_MANAGERPROPERTIESB"
Conn.execute "INSERT INTO " + """" + h + """" + " ( " + """" + aa + """" + " ," + """" + b + """" + ") values('" & cboLayer.Text & "','" & a & "')"
End If
Next
'CORREÇÃO DO BUG DO TE_IMPORT
rs.Close
Dim dw As String ' alterado em 20/10/2010
Dim dr As String
Dim dp As String
dw = "table_id"
dr = "te_layer_table"
dp = "attr_table"
If frmCanvas.TipoConexao <> 4 Then
Set rs = Conn.execute("SELECT Max(table_id) , count(*) from te_layer_table where attr_table='" & cboLayer.Text & "'")
Else
Set rs = Conn.execute("SELECT Max(" + """" + dw + """" + ") , count(*) from " + """" + dr + """" + " where " + """" + dp + """" + "='" & cboLayer.Text & "'")
End If
If Not rs.EOF Then
If rs.Fields(1).value > 1 Then
a = "te_layer_table"
b = "table_id"
If frmCanvas.TipoConexao <> 4 Then
Conn.execute ("delete from TE_LAYER_TABLE where TABLE_ID = rs.Fields(0).value")
Else
Conn.execute ("delete from " + """" + aa + """" + " where " + """" + b + """" + " ='" & rs.Fields(0).value & "'")
End If
End If
rs.Close
Set rs = Nothing
MsgBox "Importação Concluida!", vbInformation
Unload Me
While Not FrmMain.ActiveForm Is Nothing
Unload FrmMain.ActiveForm
FrmMain.SetFocus
Wend
FrmMain.tbToolBar_ButtonClick FrmMain.tbToolBar.Buttons("knew")
Else
MsgBox "Ocorreu um erro na importação!", vbInformation
End If
End If
End If
'Trata_Erro:
' If Err.Number = 0 Or Err.Number = 20 Then
' Resume Next
' Else
' PrintErro "frmImportFile", "cmdImport_Click()", CStr(Err.Number), CStr(Err.Description), True
'Resume
' End If
End Sub
Private Sub cmdOpenFile_Click()
CDL.Filter = "Arquivo Shape (*.shp)|*.shp|Arquivo SPRING (*.geo)|*.geo|Arquivo MapInfo (*.mif)|*.mif|"
CDL.FilterIndex = 1
CDL.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer
CDL.ShowOpen
txtFileName.Text = CDL.FileName
End Sub