frmUserControle.frm
7.53 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
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmUserControle
BorderStyle = 4 'Fixed ToolWindow
Caption = " Controle de Usuários GeoSan - Acesso de Administrador"
ClientHeight = 2895
ClientLeft = 45
ClientTop = 315
ClientWidth = 10935
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2895
ScaleWidth = 10935
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdExcluir
Caption = "Excluir"
Height = 400
Left = 9660
TabIndex = 4
Top = 1395
Width = 1120
End
Begin VB.CommandButton cmdEditar
Caption = "Editar"
Height = 400
Left = 9660
TabIndex = 3
Top = 930
Width = 1120
End
Begin VB.CommandButton cmdNovo
Caption = "Novo"
Height = 400
Left = 9660
TabIndex = 2
Top = 225
Width = 1120
End
Begin MSFlexGridLib.MSFlexGrid Flex1
Height = 2490
Left = 120
TabIndex = 1
Top = 165
Width = 9375
_ExtentX = 16536
_ExtentY = 4392
_Version = 393216
Cols = 6
BackColorBkg = 14737632
FocusRect = 0
SelectionMode = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.CommandButton cmdFechar
Caption = "Fechar"
Height = 400
Left = 9660
TabIndex = 0
Top = 2235
Width = 1120
End
End
Attribute VB_Name = "frmUserControle"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Co As Integer
Dim Li As Integer
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
Private Sub cmdExcluir_Click()
If Flex1.TextMatrix(Flex1.Row, 1) = "Admin. do Sistema" Then
MsgBox "O usuário 'Admin. do Sistema' não pode ser excluído.", vbOKOnly + vbExclamation, "Excluir"
Exit Sub
End If
If MsgBox("Confirma exclusão do usuário '" & Flex1.TextMatrix(Flex1.Row, 2) & "' ?", vbQuestion + vbYesNo + vbDefaultButton2, "Excluir") = vbYes Then
a = "SYSTEMUSERS"
b = "USRLOG"
If frmCanvas.TipoConexao <> 4 Then
Conn.execute ("DELETE FROM SYSTEMUSERS WHERE USRLOG = '" & Flex1.TextMatrix(Flex1.Row, 2) & "' ")
Else
Conn.execute ("DELETE FROM " + """" + a + """" + " WHERE " + """" + b + """" + " = '" & Flex1.TextMatrix(Flex1.Row, 2) & "' ")
End If
CarregaForm
End If
End Sub
Private Sub Flex1_DblClick()
Editar
CarregaForm
End Sub
Private Sub cmdEditar_Click()
Editar
CarregaForm
End Sub
Private Function Editar()
FrmUser.txtLogin.Text = Flex1.TextMatrix(Flex1.Row, 2)
FrmUser.txtLoginOld.Text = Flex1.TextMatrix(Flex1.Row, 2)
FrmUser.txtNome.Text = Flex1.TextMatrix(Flex1.Row, 1)
FrmUser.txtDepto.Text = Flex1.TextMatrix(Flex1.Row, 4)
FrmUser.txtEmail.Text = Flex1.TextMatrix(Flex1.Row, 5)
FrmUser.txtSenha.Text = Flex1.TextMatrix(Flex1.Row, 8)
If FrmUser.txtNome.Text = "Admin. do Sistema" Then
FrmUser.optAdministrador.value = True
FrmUser.txtLogin.Enabled = False
FrmUser.chkBloqueado.value = False
FrmUser.chkBloqueado.Enabled = False
FrmUser.Frame2.Enabled = False
End If
If Flex1.TextMatrix(Flex1.Row, 7) = "Sim" Then
FrmUser.chkBloqueado.value = 1
End If
If Flex1.TextMatrix(Flex1.Row, 3) = "Administrador" Then
FrmUser.optAdministrador = True
ElseIf Flex1.TextMatrix(Flex1.Row, 3) = "Usuário" Then
FrmUser.optUsuario = True
ElseIf Flex1.TextMatrix(Flex1.Row, 3) = "Visitante" Then
FrmUser.optVisitante = True
ElseIf Flex1.TextMatrix(Flex1.Row, 3) = "Visualizador" Then
FrmUser.optViewer = True
End If
FrmUser.Caption = " Usuário - Editar"
FrmUser.txtNome.Enabled = False
FrmUser.Show 1
End Function
Private Sub cmdFechar_Click()
Unload Me
End Sub
Private Sub cmdNovo_Click()
FrmUser.Caption = " Usuário - Novo"
FrmUser.Show 1
CarregaForm
End Sub
Private Function CarregaForm()
On Error GoTo Trata_Erro
Flex1.Clear
Flex1.Rows = 1
Flex1.Cols = 9
Flex1.ColWidth(0) = 350
Flex1.ColWidth(1) = 1700 '"Nome do usuário"
Flex1.ColWidth(2) = 1300 '"Login"
Flex1.ColWidth(3) = 1100 '"Permissão"
Flex1.ColWidth(4) = 2000 '"Departamento"
Flex1.ColWidth(5) = 1950 '"E-mail"
Flex1.ColWidth(6) = 900 '"Data"
Flex1.ColWidth(7) = 900 '"Bloqueado"
Flex1.ColWidth(8) = 0 '"Senha
Flex1.TextMatrix(0, 1) = "Nome do usuário"
Flex1.TextMatrix(0, 2) = "Login"
Flex1.TextMatrix(0, 3) = "Permissão"
Flex1.TextMatrix(0, 4) = "Departamento"
Flex1.TextMatrix(0, 5) = "E-mail"
Flex1.TextMatrix(0, 6) = "Data"
Flex1.TextMatrix(0, 7) = "Bloqueado"
Dim rs As ADODB.Recordset
a = "SYSTEMUSERS"
b = "USRNOM"
If frmCanvas.TipoConexao <> 4 Then
Set rs = Conn.execute("SELECT * FROM SYSTEMUSERS ORDER BY USRNOM")
Else
Set rs = Conn.execute("SELECT * FROM " + """" + a + """" + " ORDER BY " + """" + b + """" + "")
End If
If rs.EOF = False Then
rs.MoveFirst
Li = 1
Do While Not rs.EOF = True
Flex1.Rows = Flex1.Rows + 1
Flex1.TextMatrix(Li, 1) = rs!UsrNom
Flex1.TextMatrix(Li, 2) = rs!UsrLog
If rs!UsrFun = 1 Then
Flex1.TextMatrix(Li, 3) = "Administrador"
ElseIf rs!UsrFun = 2 Then
Flex1.TextMatrix(Li, 3) = "Usuário"
ElseIf rs!UsrFun = 3 Then
Flex1.TextMatrix(Li, 3) = "Visitante"
Else
Flex1.TextMatrix(Li, 3) = "Visualizador"
End If
Flex1.TextMatrix(Li, 4) = rs!USRDEPTO
Flex1.TextMatrix(Li, 5) = rs!USRMAIL
Flex1.TextMatrix(Li, 6) = Format(rs!USRDATA, "00-00-0000")
If rs!UsrBrk <> 0 Then
Flex1.TextMatrix(Li, 7) = "Sim"
Else
Flex1.TextMatrix(Li, 7) = "Não"
End If
Flex1.TextMatrix(Li, 8) = rs!UsrPwd
Li = Li + 1
rs.MoveNext
Loop
End If
Trata_Erro:
If Err.Number = 0 Or Err.Number = 20 Then
Resume Next
ElseIf Err.Number = 3265 Then
Err.Clear
Resume Next
ElseIf Err.Number = 94 Then
Err.Clear
Resume Next
Else
PrintErro CStr(Me.Name), "Private Function CarregaForm()", CStr(Err.Number), CStr(Err.Description), True
End If
End Function
Private Sub Form_Load()
CarregaForm
End Sub
Private Sub Flex1_Click()
'MsgBox Flex1.TextMatrix(Flex1.Row, 2)
Li = Flex1.Row
Co = 2
End Sub