-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistor~1.frm
369 lines (347 loc) · 11.1 KB
/
Histor~1.frm
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
VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form frmHistoricoCliente
Caption = "Históricos de Clientes"
ClientHeight = 4455
ClientLeft = 255
ClientTop = 1530
ClientWidth = 6255
LinkTopic = "Form3"
MDIChild = -1 'True
PaletteMode = 1 'UseZOrder
ScaleHeight = 4455
ScaleWidth = 6255
Begin VB.CommandButton cmdInclusao
Caption = "&Incluir"
Height = 420
Left = 4860
TabIndex = 12
Top = 315
Width = 1230
End
Begin VB.CommandButton cmdAlteracao
Caption = "&Alterar"
Height = 420
Left = 4860
TabIndex = 13
Top = 945
Width = 1230
End
Begin VB.CommandButton cmdExclusao
Caption = "&Excluir"
Height = 420
Left = 4860
TabIndex = 14
Top = 1665
Width = 1230
End
Begin VB.CommandButton cmdSaida
Caption = "&Retornar"
Height = 420
Left = 4860
TabIndex = 15
Top = 3510
Width = 1230
End
Begin VB.TextBox txtDescricao
Height = 2130
Left = 180
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 11
Top = 2205
Width = 4380
End
Begin VB.TextBox txtAssunto
Height = 285
Left = 180
MaxLength = 20
TabIndex = 9
Top = 1575
Width = 3255
End
Begin VB.ComboBox cmbOrdem
Height = 315
Left = 180
Style = 2 'Dropdown List
TabIndex = 5
Top = 900
Width = 915
End
Begin VB.ComboBox cmbCodinome
Height = 315
Left = 180
Style = 2 'Dropdown List
TabIndex = 1
Top = 315
Width = 2490
End
Begin MSMask.MaskEdBox mskData
Height = 330
Left = 1215
TabIndex = 7
Top = 900
Width = 1005
_ExtentX = 1773
_ExtentY = 582
_Version = 327680
MaxLength = 8
Format = "ddddd"
Mask = "##/##/##"
PromptChar = " "
End
Begin MSMask.MaskEdBox mskCPF_CGC
Height = 330
Left = 2760
TabIndex = 3
Top = 315
Width = 1860
_ExtentX = 3281
_ExtentY = 582
_Version = 327680
PromptInclude = 0 'False
MaxLength = 18
Mask = "##.###.###/####-##"
PromptChar = " "
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "Data"
Height = 195
Left = 1260
TabIndex = 6
Top = 720
Width = 345
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "Descrição"
Height = 195
Left = 180
TabIndex = 10
Top = 1980
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "Assunto"
Height = 195
Left = 180
TabIndex = 8
Top = 1350
Width = 570
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "Ordem"
Height = 195
Left = 180
TabIndex = 4
Top = 720
Width = 465
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Clientes Cadastrados"
Height = 195
Left = 180
TabIndex = 0
Top = 90
Width = 1485
End
Begin VB.Label Label2
Caption = "CPF/CGC"
Height = 195
Left = 2805
TabIndex = 2
Top = 90
Width = 1230
End
End
Attribute VB_Name = "frmHistoricoCliente"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'************************************************
' Este código foi retirado da Seriallink.com *
' www.seriallink.com *
' UESLEI R. VALENTINI ([email protected]) *
' Última Revisão: 25/08/99 *
'************************************************
'+--------------------------------------------------------+
'| Projeto: CPR - Contas a Pagar e a Receber |
'| Autor: Adilson da Silva Lima |
'| Data: 17/07/1997 |
'+--------------------------------------------------------+
'| Descrição: Formulário para cadastro de históricos de |
'| clientes |
'+--------------------------------------------------------+
Private Sub cmbCodinome_Click()
Dim Selecao As String
Selecao = "select * from Cliente where Codinome=" & """"
Selecao = Selecao & cmbCodinome.Text & """"
Set Tabela = Banco.OpenRecordset(Selecao, dbOpenSnapshot)
' Configuração da máscara a partir da coluna "Tabela("CPF_CGC")"
Select Case Len(Tabela("CPF_CGC"))
Case Is = 11
mskCPF_CGC.Mask = "###.###.###-##"
Case Is = 14
mskCPF_CGC.Mask = "##.###.###/####-##"
End Select
mskCPF_CGC.Text = Tabela("CPF_CGC")
Tabela.Close
'Executa seleção na tabela de históricos a partir do CPF/CGC do _
cliente selecionado (utilizando o mesmo objeto recordset)
Selecao = "select * from HistoricoCliente where CPF_CGC="
Selecao = Selecao & mskCPF_CGC
Set Tabela = Banco.OpenRecordset(Selecao, dbOpenSnapshot)
' Limpa o combo CMBORDEM e alimenta-o com todos os números de ordem _
dos históricos do cliente selecionados
cmbOrdem.Clear
Do Until Tabela.EOF
cmbOrdem.AddItem Tabela("Ordem")
Tabela.MoveNext
Loop
' O método CLOSE fecha o recordset, evitando que ele fique aberto após _
sua utilização
Tabela.Close
End Sub
Private Sub cmbOrdem_Click()
Selecao = "SELECT * From HistoricoCliente WHERE CPF_CGC = "
Selecao = Selecao & mskCPF_CGC
Selecao = Selecao & " and Ordem = " & cmbOrdem
Set Tabela = Banco.OpenRecordset(Selecao, dbOpenSnapshot)
If Tabela.RecordCount = 0 Then
Tabela.Close
Exit Sub
End If
mskData = Tabela("data")
txtAssunto = Tabela("Assunto")
txtDescricao = Tabela("Descricao")
Tabela.Close
End Sub
Private Sub cmdAlteracao_Click()
GravaHistoricoCliente 2
cmbOrdem.SetFocus
End Sub
Private Sub cmdExclusao_Click()
If Trim$(mskCPF_CGC) = "" Then
MsgBox "Informe o número de CPF/CGC", 16, "Exclusão"
mskCPF_CGC.SetFocus
Exit Sub
End If
If cmbOrdem.ListIndex = -1 Then
MsgBox "Informe o número de ordem", 16, "Exclusão"
cmbOrdem.SetFocus
Exit Sub
End If
If MsgBox("Confirme a exclusão do histórico", 36, "Exclusão") <> 6 Then
Exit Sub
End If
On Error GoTo ErrExcluiHistoricoCliente
Set Consulta = Banco.QueryDefs("DelHistoricoCliente")
Consulta("parCPF_CGC") = mskCPF_CGC.Text
Consulta("parOrdem") = cmbOrdem.Text
Consulta.Execute
mskCPF_CGC.Text = ""
mskData = ""
txtAssunto = ""
txtDescricao = ""
cmbCodinome_Click
Exit Sub
ErrExcluiHistoricoCliente:
MsgBox MensErro, 16, "Falha na exclusão do histórico"
Exit Sub
End Sub
Private Sub cmdInclusao_Click()
GravaHistoricoCliente 1
cmbOrdem.SetFocus
End Sub
Private Sub cmdSaida_Click()
Unload Me
End Sub
Private Sub Form_Load()
' A rotina ComboCliente foi invocada na leitura do formulário-chamador _
(frmCliente) e, aqui, uma segunda vez...
' Note que em FRMCLIENTE também possuímos um combobox denominado CMBCODINOME: _
esses dois controles possuem comportamento independente!
ComboCliente cmbCodinome
End Sub
Private Sub mskCPF_CGC_GotFocus()
mskCPF_CGC.Mask = "##############"
End Sub
Private Sub mskCPF_CGC_LostFocus()
Dim temp As String
temp = mskCPF_CGC
Select Case Len(mskCPF_CGC)
Case Is = 11
mskCPF_CGC.Mask = "###.###.###-##"
Case Is = 14
mskCPF_CGC.Mask = "##.###.###/####-##"
End Select
mskCPF_CGC = temp
End Sub
Private Sub mskData_LostFocus()
' Em vez de tratar a data através do evento "ValidationError", _
preferimos ilustrar aqui a utilização de uma função genérica construída _
para a consistência de datas.
If Not ConsisteData(mskData) Then mskData.SetFocus
End Sub
Private Sub GravaHistoricoCliente(Operacao As Integer)
Dim Titulo As String
If Operacao = 1 Then
Titulo = "Inclusão"
Else
Titulo = "Alteração"
End If
If Trim$(mskCPF_CGC) = "" Then
MsgBox "Informe o número de CPF/CGC", 16, Titulo
mskCPF_CGC.SetFocus
Exit Sub
End If
If Len(Trim$(mskCPF_CGC)) <> 11 And Len(Trim$(mskCPF_CGC)) <> 14 Then
MsgBox "Corrija o número de CPF/CGC", 16, Titulo
mskCPF_CGC.SetFocus
Exit Sub
End If
If Trim$(mskData) = "" Then
MsgBox "Informe a data do histórico", 16, Titulo
mskData.SetFocus
Exit Sub
End If
If Operacao <> 1 And cmbOrdem.ListIndex = -1 Then
MsgBox "Informe o número de ordem", 16, Titulo
cmbOrdem.SetFocus
Exit Sub
End If
Dim MensErro As String, ErroPar As Integer
On Error GoTo ErrGravaHistoricoCliente
ErroPar = False
MensErro = "Falha na abertura da consulta"
If Operacao = 1 Then
Set Consulta = Banco.QueryDefs("InsHistoricoCliente")
Else
Set Consulta = Banco.QueryDefs("UpdHistoricoCliente")
End If
ErroPar = True
Area.BeginTrans
MensErro = "Falha na alimentação dos parâmetros"
If Operacao <> 1 Then
Consulta("parOrdem") = cmbOrdem.Text
End If
Consulta("parCPF_CGC") = mskCPF_CGC.Text
Consulta("parData") = mskData
Consulta("parAssunto") = txtAssunto
Consulta("parDescricao") = txtDescricao
MensErro = "Falha na gravação dos dados"
Consulta.Execute
Area.CommitTrans
cmbCodinome_Click
cmbCodinome.SetFocus
Exit Sub
ErrGravaHistoricoCliente:
MsgBox MensErro, 16, "Atualização de Histórico de Cliente"
If ErroPar Then Area.Rollback
Exit Sub
End Sub