-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menus.vb
304 lines (234 loc) · 11.6 KB
/
Menus.vb
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
Imports System.Threading
Public Class Menus
Private Thr_Back As Thread = Nothing
Dim Bol_Thrd As Boolean
Dim Str_Thrd As String
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Private Sub SobreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SobreToolStripMenuItem.Click
Obj_Gene.Sub_Abre(True, Sobre)
End Sub
Private Sub Menus_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Bol_Fech As Boolean
If Not Bol_Fech Then
'Obj_Gene.Sub_Hace("O sistema foi encerrado pelo usuário", False)
Bol_Fech = True
End If
End Sub
Private Sub Menus_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Ado_Auxi As New ADODB.Recordset
Dim Fol_Diag As New FolderBrowserDialog
Dim Dst_Teste As New DataSet
Dim Str_Chav As String
'Pega o serial da maquina
If Not Obj_Gene.SerialNumber(Mid$(My.Computer.FileSystem.Drives(0).ToString, 1, 2)) = "" Then
Glb_Seri = Crypto.Encrypt(Obj_Gene.SerialNumber(Mid$(My.Computer.FileSystem.Drives(0).ToString, 1, 2)))
End If
If Obj_Gene.Fun_Nulo(Glb_Seri) = "" Then
MsgBox("Erro critico de sistema! Não foi possivel localizar o número de série da máquina. Por favor contacte o suporte.", MsgBoxStyle.Critical, "Erro fatal")
End
End If
'Testa se existe o banco no caminho da pasta
If FileIO.FileSystem.FileExists(Application.StartupPath & "\Data\" & Glb_Banc) = True Then
Glb_Path = Application.StartupPath & "\Data\"
Else
If FileIO.FileSystem.FileExists(Application.StartupPath & "\Server.dll") = True Then
Glb_Path = FileIO.FileSystem.ReadAllText(Application.StartupPath & "\Server.dll")
Else
MsgBox("Não foi possível encontrar o banco de dados. Favor reinstalar o aplicativo!.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Erro crítico")
End
End If
' MsgBox("Não foi possível encontrar o banco de dados. Favor reinstalar o aplicativo!.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Erro crítico")
' End
End If
'Conecta o banco
Obj_Gene.Sub_CBan()
Lic_Veri:
'Procura a dll de registro
If FileIO.FileSystem.FileExists(Application.StartupPath & "\adodb29.dll") Then
'Tira a encriptação da chave
Str_Chav = FileIO.FileSystem.ReadAllText(Application.StartupPath & "\adodb29.dll")
For int_loop As Integer = 0 To 1
Str_Chav = StrReverse(Str_Chav)
Str_Chav = Crypto.Decrypt(Str_Chav)
Next
Str_Chav = Mid(Str_Chav, 1, Len(Crypto.Decrypt(Glb_Seri)))
If Not Str_Chav = Crypto.Decrypt(Glb_Seri) Then
'MsgBox(Crypto.Decrypt(Glb_Seri))
MsgBox("Problema ao validar licensa, por favor contacte o suporte!", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Erro fatal")
On Error Resume Next
FileIO.FileSystem.DeleteFile(Application.StartupPath & "\adodb29.dll")
End
End If
Else
Licensa.ShowDialog()
GoTo Lic_Veri
End If
Err_Next:
'Arruma os botões
Obj_Gene.Sub_Stat(Me.Text, Sta_Bar1) 'Serve para colocar o nome bonitinho na status bar
For Each Botao As ToolStripButton In Tsp_Btns.Items
Tsp_Btns.Items(Botao.Name).Enabled = False
Tsp_Btns.Items(Botao.Name).Visible = False
Next
Men_Fech.Enabled = False
'Cria o thread do teste de internet
CheckForIllegalCrossThreadCalls = False '-----------------> Isso aqui serve pra evitar que o thread ilegal aconteça!
Thr_Back = New Thread(AddressOf ThreadTask) 'Identifica qual será o procedimento a executar em segundoplano
Thr_Back.IsBackground = True 'Diz que ele será executado em segundo plano
Thr_Back.Start() 'dispara o incio do thread
'só para liberação do cadastro de clientes
'Men_Reci.Enabled = False
'Men_Reci.Visible = False
End Sub
Private Sub ArquivoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ArquivoToolStripMenuItem.Click
On Error GoTo Err_Fech
Men_Fech.Enabled = ActiveMdiChild.Enabled
Exit Sub
Err_Fech:
Men_Fech.Enabled = False
End Sub
Private Sub SairToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SairToolStripMenuItem.Click
End
End Sub
Private Sub Men_Fech_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Men_Fech.Click
On Error Resume Next
Obj_Gene.Sub_Abre(False, ActiveMdiChild)
Obj_Gene.Sub_Fech()
Men_Fech.Enabled = ActiveMdiChild.Enabled
End Sub
Private Sub Cmd_Novo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_Novo.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Incl()
End If
End Sub
Private Sub Cmd_Salv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_Salv.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Salv()
End If
End Sub
Private Sub Cmd_Prox_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cmd_Prox.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Prox()
End If
End Sub
Private Sub Cmd_Ante_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cmd_Ante.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Ante()
End If
End Sub
Private Sub Cmd_Dele_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cmd_Dele.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Dele()
End If
End Sub
Private Sub Cmd_Prnt_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cmd_Prnt.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Impr()
End If
End Sub
'Private Sub MudarFundoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Dim Ado_Auxi As New ADODB.Recordset
' Dim Str_Path As String
' 'Muda o fundo de tela
' Glb_Pesq = "Select * from Dados_Visual where Seri = '" & Glb_Seri & "'"
' Obj_Gene.Sub_Crec(Ado_Auxi, Glb_Pesq)
' Opn_File.FileName = ""
' Opn_File.Filter = "Todas as imagens suportadas|*.jpg;*.bmp;*.jpeg;*.png;"
' Opn_File.Title = "Abrir imagem..."
' If Opn_File.ShowDialog() = Windows.Forms.DialogResult.OK Then
' If Trim$(Opn_File.FileName) = "" Then Exit Sub
' Str_Path = Opn_File.FileName
' If Not FileIO.FileSystem.FileExists(Str_Path) Then
' MsgBox("Arquivo inexistente!", MsgBoxStyle.Information, Me.Text)
' Exit Sub
' End If
' If Ado_Auxi.EOF Then
' Ado_Auxi.AddNew()
' End If
' FileIO.FileSystem.CopyFile(Str_Path, Application.StartupPath & "\Image\" & Glb_Seri & ".Jpg", True)
' Str_Path = Application.StartupPath & "\Image\" & Glb_Seri & ".Jpg"
' Ado_Auxi("Imag").Value = Str_Path
' Ado_Auxi("Seri").Value = Glb_Seri
' Ado_Auxi.Update()
' Me.BackgroundImage = Image.FromFile(Ado_Auxi(0).Value)
' Me.Refresh()
' MsgBox("Imagem alterada com êxito!", MsgBoxStyle.Information, Me.Text)
' End If
'End Sub
'Private Sub RemoverFundoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Dim Ado_Auxi As New ADODB.Recordset
' Dim Str_File As String
' If Me.BackgroundImage Is Nothing Then Exit Sub
' Me.BackgroundImage = Nothing
' Me.Refresh()
' 'Apaga a imagem de fundo da pasta
' Str_File = Application.StartupPath & "\Image\" & Glb_Seri & ".Jpg"
' If FileIO.FileSystem.FileExists(Str_File) Then FileIO.FileSystem.DeleteFile(Str_File)
' 'remove o fundo de tela
' Glb_Pesq = "Delete * from Dados_Visual where Seri = '" & Glb_Seri & "'"
' Ado_Conn.Execute(Glb_Pesq)
' MsgBox("Imagem removida com êxito!", MsgBoxStyle.Information, Me.Text)
'End Sub
Private Sub Cmd_Pesq_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_Pesq.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Pesq()
End If
End Sub
Private Sub Menus_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseHover
Obj_Gene.Sub_Tags(sender)
End Sub
Private Sub Cmd_Prim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_Prim.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Prim()
End If
End Sub
Private Sub Cmd_Ulti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmd_Ulti.Click
Dim activeForm = TryCast(ActiveMdiChild, Obj_Func)
If activeForm IsNot Nothing Then
activeForm.Sub_Ulti()
End If
End Sub
Private Sub Men_Clie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Men_Clie.Click
Men_Clie.Enabled = False
Obj_Gene.Sub_Abre(True, Cadastro_Projetos)
End Sub
Sub ThreadTask()
'Verifica a conexão com a internet
Do
If Obj_Gene.Fun_Inte("http://cep.republicavirtual.com.br/") Then
Tst_Internet.ForeColor = Color.Green
Tst_Internet.Text = "Conexão com a internet ativa"
Tst_Internet.ToolTipText = ""
Else
Tst_Internet.ForeColor = Color.Red
Tst_Internet.Text = "Conexão da internet perdida"
Tst_Internet.ToolTipText = "Talvez alguns itens não estejam disponíveis, como por exemplo a consulta de CEP."
End If
Thread.Sleep(1000)
Loop
End Sub
Private Sub Men_Reci_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Men_Reci.Click
Men_Reci.Enabled = False
Obj_Gene.Sub_Abre(True, Recibos)
End Sub
Private Sub Men_Empr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Men_Empr.Click
Men_Empr.Enabled = False
Obj_Gene.Sub_Abre(True, Dados_Empresa)
End Sub
Private Sub Men_Irec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Men_Irec.Click
Men_Irec.Enabled = False
Obj_Gene.Sub_Abre(True, Impressao_Recibos)
End Sub
Private Sub AtualizaçãoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AtualizaçãoToolStripMenuItem.Click
MsgBox("Serviço ainda não disponível." & vbCrLf & "Favor verificar as atualizações manualmente no site do desenvolvedor", MsgBoxStyle.Information, "Não disponível")
'Atualizar.ShowDialog()
End Sub
End Class