Vous êtes sur la page 1sur 7

FORM 2 Private Sub cmdfirst_Click() rs.MoveFirst FillFields txtname.Enabled = True txtposition.Enabled = True txtgross.Enabled = True txtdeduct.Enabled = True txtnet.

Enabled = True End Sub Private Sub cmdlast_Click() rs.MoveLast 'go to the last record FillFields 'fill the controls txtname.Enabled = True txtposition.Enabled = True txtgross.Enabled = True txtdeduct.Enabled = True txtnet.Enabled = True End Sub Private Sub cmdmenu_Click() Form3.Show Unload Me End Sub Private Sub cmdnext_Click() If Not (rs.BOF = True And rs.EOF = True) Then rs.MoveNext If Not rs.EOF Then FillFields 'fill the controls Else rs.MoveLast MsgBox "Last record reached! ", vbExclamation, "Status" End If Else MsgBox "No record is existing, Move Next not allowed! ", vbExclamation, "No Record" End If End Sub Private Sub cmdprevious_Click() If Not (rs.BOF = True And rs.EOF = True) Then rs.MovePrevious If Not rs.BOF Then FillFields Else

If Not rs.EOF Then rs.MoveFirst End If MsgBox "First record reached! ", vbExclamation, "Status" End If Else MsgBox "No record is existing, Move Previous not allowed! ", vbExclamation, "No Record" End If End Sub Private Sub cmdsearch_Click() Dim csrc As String Set rs = New ADODB.Recordset csrc = InputBox("Enter Payslip", "Search") rs.Open " select * from tblsalary where payslip = '" & csrc & "'", con, adOpenKeyset, adLockOptimistic If rs.RecordCount <> 0 Then FillFields txtname.Enabled = True txtposition.Enabled = True txtgross.Enabled = True txtdeduct.Enabled = True txtnet.Enabled = True Else MsgBox " No data found", vbCritical, "hello" End If rs.Close Set rs = Nothing End Sub Public Sub FillFields() If Not (rs.BOF = True Or rs.EOF = True) Then txtname.Text = rs.Fields("employee") txtposition.Text = rs.Fields("position") Frame1.Caption = rs.Fields("payslip") txtgross.Text = rs.Fields("grosss") txtdeduct.Text = rs.Fields("deduct") txtnet.Text = rs.Fields("net") Else txtpayslip.Text = "" txtname.Text = "" txtposition.Text = "" txtgross.Text = "" txtdeduct.Text = "" txtnet.Text = ""

End If End Sub Private Sub Form_Load() Set con = Nothing Set con = New ADODB.Connection con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\jay.mdb" con.Open con.CursorLocation = adUseClient Set rs = Nothing Set rs = New ADODB.Recordset rs.Open "Select * from tblsalary", con, adOpenDynamic, adLockOptimistic txtname.Enabled = True txtposition.Enabled = True txtgross.Enabled = True txtdeduct.Enabled = True txtnet.Enabled = True End Sub FORM 1 Dim gross, deduct, net As Double Private Sub cmdcompute_Click() Dim gross, deduct, net As Integer gross = Val(txtrate.Text) * Val(txtworked.Text) deduct = Val(txtsss.Text) + Val(txtpagibig.Text) + Val(txttax.Text) net = gross - deduct If gross >= 10000 Then txttax.Text = 2000 txtsss.Text = 750 txtpagibig.Text = 950 Else txttax.Text = 1000 txtsss.Text = 500 txtpagibig.Text = 650 End If

End Sub Sub clear() txtpayslip.Text = "" txtname.Text = "" txtposition = "" txtrate.Text = "" txtworked = "" txtsss.Text = "" txtpagibig.Text = "" txttax.Text = "" End Sub Private Sub cmddelete_Click() txtpayslip.Text = "" txtname.Text = "" txtposition.Text = "" txtrate.Text = "" txtworked.Text = "" txtsss.Text = "" txtpagibig.Text = "" txttax.Text = "" End Sub

Private Sub cmdmenu_Click() Form3.Show Unload Me End Sub Private Sub cmdsave_Click() Dim gross, deduct, net As Integer gross = Val(txtrate.Text) * Val(txtworked.Text) deduct = Val(txtsss.Text) + Val(txtpagibig.Text) + Val(txttax.Text) net = gross - deduct rs.AddNew rs!payslip = txtpayslip.Text rs!employee = txtname.Text rs!position = txtposition.Text rs!Rate = txtrate.Text rs!no_hrsw = txtworked.Text rs!sss = txtsss.Text

rs!pagibig = txtpagibig.Text rs!tax = txttax.Text rs!grosss = gross rs!deduct = deduct rs!net = net rs.Update MsgBox "successfully saved", vbOKOnly + vbInformation, "information" End Sub Private Sub cmdtype_Click() If Option1 = True Then txtposition.Text = "INSTRUCTOR" Else txtposition.Text = "REGULAR EMPLOYEE" End If End Sub Private Sub Form_Load() opendb Set con = Nothing Set con = New ADODB.Connection con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data source=" & App.Path & "\jay.mdb" con.Open con.CursorLocation = adUseClient Set rs = Nothing Set rs = New ADODB.Recordset rs.Open "select * from tblsalary ", con, adOpenDynamic, adLockOptimistic End Sub Public Sub FillFields() If Not (rs.BOF = True Or rs.EOF = True) Then record. This is use a lot. txtpayslip.Text = rs.Fields("payslip") txtname.Text = rs.Fields("employee") txtposition.Text = rs.Fields("position") txtrate.Text = rs.Fields("rate") txtworked.Text = rs.Fields("no_hrsw") txtsss.Text = rs.Fields("sss") 'Checks if we are at the first or last

txtpagibig.Text = rs.Fields("pagibig") txttax.Text = rs.Fields("tax") Else txtpayslip.Text = "" txtname.Text = "" txtposition.Text = "" txtrate.Text = "" txtworked.Text = "" txtsss.Text = "" txtpagibig.Text = "" txttax.Text = "" End If End Sub MODULE Public con As New ADODB.Connection Public rs As New ADODB.Recordset Sub Main() opendb Form3.Show End Sub Sub opendb() Set con = Nothing Set con = New ADODB.Connection con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\jay.mdb" con.Open con.CursorLocation = adUseClient If con.State = 1 Then MsgBox "successfully connected" Form3.Show Else MsgBox "not connected" End If End Sub Sub realopendb() Set con = Nothing Set con = New ADODB.Connection con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & App.Path & "\jay.mdb" con.Open con.CursorLocation = adUseClient

End Sub FORM 3 rivate Sub cmdpayslip_Click() Form1.Show Unload Me End Sub Private Sub cmdsearch_Click() Form2.Show Unload Me End Sub

Vous aimerez peut-être aussi