You are on page 1of 8

Dim db As Database 'iniciar de -p+

Dim tb As Recordset
Dim btn As Integer
Dim vCod_cliente As Long
Dim checkbox As Integer
Dim vvalor, vvalor2, vvalor3

Private Sub Check1_Click()


If Check1.Value = 1 Then
Text2.Visible = False
Text3.Visible = False
Text7.Visible = True
cmdcalcular.Visible = False
Command4.Visible = True
Else
Text2.Visible = True
Text3.Visible = True
Text7.Visible = False
cmdcalcular.Visible = True
Command4.Visible = False
End If
End Sub

Private Sub cmdalt_Click()

If Trim(tes1.Text = "") Then


MsgBox "Digite o SAT.", , "Pakari"
tes1.SetFocus
Exit Sub
End If

tb.Seek "=", tes1.Text


If tb.NoMatch Then
MsgBox "SAT N�o Cadastrado.", , "Pakari"
limpe
Else
fratel.Enabled = False
fradados.Enabled = True
cliente.SetFocus
cliente.Text = tb("Cliente")
norma.Text = tb("NORMA")
forno.Text = tb("Indentificacao")
data.Text = tb("Data")
hora.Text = tb("Hora")
Termopar.Text = tb("Termopar")
sensor.Text = tb("Sensor Testado")
teste.Text = tb("Sensor de Teste")
Instrumento.Text = tb("Intrumento de Teste")
Text6.Text = tb("A")
Text1.Text = tb("B")
Text2.Text = tb("C")
Text3.Text = tb("D")
lbl7.Caption = tb("E")
Text4.Text = tb("AE")
Frmconclusao.tes2.Text = tb("TES2")
Frmconclusao.comentario.Text = tb("Conclusao")
Frmconclusao.comentario.Text = tb("Fatores")
Frmconclusao.Instrumento.Text = tb("Instrumento")
Frmconclusao.modelo.Text = tb("Modelo")
Frmconclusao.certificado.Text = tb("Certificado")
Frmconclusao.validade.Text = tb("Validade")
Frmconclusao.rastre.Text = tb("Rastreabilidade")

botoes
btn = 2
End If

End Sub

Private Sub cmdcad_Click()


Frmconclusao.tes2 = tes1.Text

If Trim(tes1.Text = "") Then


MsgBox "Digite o SAT.", , "Pakari"
tes1.SetFocus
End If
If Trim(hora.Text = "") Then
MsgBox "Campo Hora Obrigatorio.", , "Pakari"
End If
If Trim(data.Text = "") Then
MsgBox "Campo DATA Obrigatorio.", , "Pakari"
End If

tb.Seek "=", tes1.Text


If tb.NoMatch Then
fratel.Enabled = False
fradados.Enabled = True
cliente.SetFocus
botoes
btn = 1
Else
MsgBox "SAT j� cadastrado.", , "Pakari"
limpe
End If

End Sub

Private Sub cmdcalc_Click()


Calculator.Show
End Sub

Private Sub cmdcan_Click()


limpe
End Sub

Private Sub cmdcf_Click()

If btn = 1 Then
tb.AddNew
tb("Cliente") = cliente.Text
tb("NORMA") = norma.Text
tb("Indentificacao") = forno.Text
tb("TES") = tes1.Text
tb("Data") = data.Text
tb("Hora") = hora.Text
tb("Termopar") = Termopar.Text
tb("Sensor Testado") = sensor.Text
tb("Sensor de Teste") = teste.Text
tb("Intrumento de Teste") = Instrumento.Text
tb("A") = Text6.Text
tb("B") = Text1.Text
tb("C") = Text2.Text
tb("D") = Text3.Text
tb("E") = lbl7.Caption
tb("AE") = Text5.Text
tb("TES2") = Frmconclusao.tes2.Text
tb("Fatores") = Frmconclusao.fatores.Text
tb("Conclusao") = Frmconclusao.comentario.Text
tb("Instrumento") = Frmconclusao.Instrumento.Text
tb("Modelo") = Frmconclusao.modelo.Text
tb("Certificado") = Frmconclusao.certificado.Text
tb("Validade") = Frmconclusao.validade.Text
tb("Rastreabilidade") = Frmconclusao.rastre.Text

tb.Update
limpe
End If

If btn = 2 Then
tb.Edit
tb("Cliente") = cliente.Text
tb("NORMA") = norma.Text
tb("Indentificacao") = forno.Text
tb("TES") = tes1.Text
tb("Data") = data.Text
tb("Hora") = hora.Text
tb("Termopar") = Termopar.Text
tb("Sensor Testado") = sensor.Text
tb("Sensor de Teste") = teste.Text
tb("Intrumento de Teste") = Instrumento.Text
tb("A") = Text6.Text
tb("B") = Text1.Text
tb("C") = Text2.Text
tb("D") = Text3.Text
tb("E") = lbl7.Caption
tb("AE") = Text5.Text
tb("TES2") = Frmconclusao.tes2.Text
tb("Fatores") = Frmconclusao.fatores.Text
tb("Conclusao") = Frmconclusao.comentario.Text
tb("Instrumento") = Frmconclusao.Instrumento.Text
tb("Modelo") = Frmconclusao.modelo.Text
tb("Certificado") = Frmconclusao.certificado.Text
tb("Validade") = Frmconclusao.validade.Text
tb("Rastreabilidade") = Frmconclusao.rastre.Text

tb.Update
limpe
End If

If btn = 3 Then
tb.Delete
limpe
End If

End Sub

Private Sub cmdcon_Click()

If Trim(tes1.Text = "") Then


MsgBox "Digite o SAT.", , "Pakari"
limpe
Exit Sub
End If

tb.Seek "=", tes1.Text


If tb.NoMatch Then
MsgBox "SAT N�o Cadastrado.", , "Pakari"
tes1.Text = ""
tes1.SetFocus
Else
fratel.Enabled = False
cliente.Text = tb("Cliente")
norma.Text = tb("NORMA")
forno.Text = tb("Indentificacao")
data.Text = tb("Data")
hora.Text = tb("Hora")
Termopar.Text = tb("Termopar")
sensor.Text = tb("Sensor Testado")
teste.Text = tb("Sensor de Teste")
Instrumento.Text = tb("Intrumento de Teste")
Text6.Text = tb("A")
Text1.Text = tb("B")
Text2.Text = tb("C")
Text3.Text = tb("D")
lbl7.Caption = tb("E")
Text5.Text = tb("AE")
Frmconclusao.tes2.Text = tb("TES2")
Frmconclusao.fatores.Text = tb("Fatores")
Frmconclusao.comentario.Text = tb("Conclusao")
Frmconclusao.Instrumento.Text = tb("Instrumento")
Frmconclusao.modelo.Text = tb("Modelo")
Frmconclusao.certificado.Text = tb("Certificado")
Frmconclusao.validade.Text = tb("Validade")
Frmconclusao.rastre.Text = tb("Rastreabilidade")

botoes
cmdcf.Visible = False
cmdcan.Visible = False
cmdok.Visible = True
End If

End Sub

Private Sub cmdex_Click()


If Trim(tes1.Text = "") Then
MsgBox "Digite o SAT.", , "Pakari"
tes1.SetFocus
Exit Sub
End If

tb.Seek "=", tes1.Text


If tb.NoMatch Then
MsgBox "SAT N�o Cadastrado.", , "Pakari"
limpe
Else
fratel.Enabled = False
fradados.Enabled = True
cliente.Text = tb("Cliente")
norma.Text = tb("NORMA")
forno.Text = tb("Indentificacao")
data.Text = tb("Data")
hora.Text = tb("Hora")
Termopar.Text = tb("Termopar")
sensor.Text = tb("Sensor Testado")
teste.Text = tb("Sensor de Teste")
Instrumento.Text = tb("Intrumento de Teste")
Text6.Text = tb("A")
Text1.Text = tb("B")
Text2.Text = tb("C")
Text3.Text = tb("D")
lbl7.Caption = tb("E")
Text5.Text = tb("AE")
Frmconclusao.tes2 = tb("TES2")

fradados.Enabled = False
botoes
btn = 3
End If
End Sub
Private Sub cmdnovo_Click()
fratel.Enabled = True
fradados.Enabled = True
tes1.Text = ""
tes1.SetFocus
botoes
cmdcf.Visible = True
cmdcan.Visible = True
cmdok.Visible = True
cmdcad.Visible = True
cmdcad.Enabled = True
cmdok.Visible = False
norma.Text = Form1.Norma1.Text
Text2.Text = Form1.C.Text
Text3.Text = Form1.D.Text

End Sub

Private Sub cmdok_Click()


limpe
End Sub
Private Sub Command1_Click()
Frmconclusao.Show
End Sub

Private Sub Command2_Click()


Call Shell(App.Path & "\TES7.exe", vbNormalFocus)

End Sub

Private Sub Command5_Click()


Unload Me
Frmtes.Show
End Sub

Private Sub Command4_Click()


End Sub

Private Sub data_KeyPress(KeyAscii As Integer)


CampoDATA data, KeyAscii
If KeyAscii = 46 Then KeyAscii = 44
If KeyAscii = 44 And InStr(Text1.Text, ",") <> 0 Then
KeyAscii = 0
Exit Sub
End If
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 44 Then
KeyAscii = 0
End If

End Sub

Private Sub Form_Load()


Set db = OpenDatabase(App.Path & "\orders.mdb")
Set tb = db.OpenRecordset("Orders", dbOpenTable)
tb.Index = "TES"
norma.Text = Form1.Norma1.Text
Text2.Text = Form1.C.Text
Text3.Text = Form1.D.Text
End Sub

Private Sub hora_KeyPress(KeyAscii As Integer)

CampoHORAS hora, KeyAscii


If KeyAscii = 46 Then KeyAscii = 44
If KeyAscii = 44 And InStr(Text1.Text, ",") <> 0 Then
KeyAscii = 0
Exit Sub
End If
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 44 Then
KeyAscii = 0
End If
End Sub

Private Sub norma_Validate(Cancel As Boolean)


norma.Text = Form1.Norma1.Text

End Sub

Private Sub tes1_KeyPress(KeyAscii As Integer) 'Permitir so nomeral na textbox


CampoTES tes1, KeyAscii
If KeyAscii = 46 Then KeyAscii = 44
If KeyAscii = 44 And InStr(Text1.Text, ",") <> 0 Then
KeyAscii = 0
Exit Sub
End If
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 44 Then
KeyAscii = 0
End If
End Sub

Private Sub Text1_Validate(Cancel As Boolean)


Text1 = Text1.Text
Text1 = Replace(Text1, ",", ".")
Text1.Text = Text1
End Sub

Private Sub Text2_Validate(Cancel As Boolean)


Text2.Text = Form1.C.Text
End Sub

Private Sub Text3_Validate(Cancel As Boolean)


Text3.Text = Form1.D.Text

End Sub

Private Sub Text6_Validate(Cancel As Boolean)


Text6 = Text6.Text
Text6 = Replace(Text6, ",", ".")
Text6.Text = Text6

End Sub

Private Sub Text8_Change()

End Sub

Private Sub Timer1_Timer()


lblhora.Caption = "Hoje � " & Date & " e agora s�o " & Time

End Sub

Function botoes()
cmdnovo.Enabled = True
cmdcad.Enabled = False
cmdalt.Enabled = True
cmdex.Enabled = False
cmdcon.Enabled = False
cmdcf.Visible = True
cmdcan.Visible = True
cmdok.Visible = False
End Function

Function limpe()

forno.Text = ""
hora.Text = ""
Termopar.Text = ""
Frmconclusao.tes2.Text = ""
fradados.Enabled = False
cmdcad.Enabled = True
cmdalt.Enabled = True
cmdex.Enabled = True
cmdcon.Enabled = True
cmdcf.Visible = False
cmdcan.Visible = False
cmdok.Visible = False
fratel.Enabled = True
tes1.Text = ""
tes1.SetFocus
End Function

Public Function Calcular()


vvalor = Val(Text1.Text) - Val(Text2.Text) + Val(Text3.Text)
Text4.Text = vvalor
vvalor3 = Val(Text1.Text) - Val(Text2.Text) + Val(Text3.Text)
lbl7.Caption = vvalor3
vvalor2 = Val(Text6.Text) - (lbl7.Caption)
Text5.Text = vvalor2
Text5.Text = Format(Text5.Text, "0.0")
lbl7.Caption = Format(lbl7.Caption, "0.0")

End Function

Private Sub cmdcalcular_Click()


Calcular
End Sub

You might also like