Petrol Pump Management System Source Code
Petrol Pump Management System Source Code
The project contains 8 forms to start with first open Microsoft VB 6.0 and
select a standard exe then add the 8 forms then add an ADO control to the
project to link the database to the project. The database is created using MS
ACCESS.
Now each forms with the screen shot and the code is listed below
End Sub
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
Form4.Show
Form1.Hide
Else
MsgBox "Wrong Password.", vbCritical, "Authentication Error"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "Incorrect UserName.", vbCritical, "Authentication
Error"
Text1.Text = ""
Text1.SetFocus
.MoveNext
End If
Next i
End If
End Sub
End Sub
End Sub
So from the figure form 1 is the log in page of the project. Next page is the
front page of the project it is drawn as shown below
FORM 2(MENU):
End Sub
End Sub
Form4.Hide
End If
End Sub
CODE
Dim a As Long
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
.Close: Set rs = Nothing
If ab < cd Then
MsgBox "There Is Not Enough Oil , Please Purchase", vbExclamation,
"Sorry"
Else
cn.Open GetConnection
cn.BeginTrans
If ab = 0 Then
MsgBox "Purchase petrolium first", vbExclamation, "Error 1025"
Form6.Show
Form2.Hide
Else
cn.Execute "INSERT INTO petro VALUES('" & Null & "','" & Text2.Text &
"','" & Null & "','" & Text1.Text & "','" & Text3.Text & "','" & Null & "','" &
Null & "','" & Null & "','" & Null & "','" & Null & "','" & Form3.Text1.Text
& "','" & Null & "','" & Null & "','" & Null & "','" & Form3.Text2.Text &
"','" & Form3.Text4.Text & "','" & Form3.Text6.Text & "','" &
Form3.Text8.Text & "','" & Text17.Text & "','" & Text18.Text & "','" &
Text18.Text & "')"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End If
cn.CommitTrans
cn.Close: Set cn = Nothing
ab = 0
cd = 0
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
.Close: Set rs = Nothing
cn.Open GetConnection
a=1
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
If a < !inde Then
a = !inde
End If
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text18.Text = a + 1
Text15.Text = ab - cd
End Sub
ab = 0
cd = 0
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
.Close: Set rs = Nothing
cn.Close: Set cn = Nothing
End With
Next i
If ab < cd Then
MsgBox "There Is Not Enough Oil , Please Purchase", vbExclamation,
"Sorry"
Else
If ab = 0 Then
MsgBox "Purchase petrolium first", vbExclamation, "Error 1025"
Form6.Show
Form2.Hide
Else
cn.Open GetConnection
cn.BeginTrans
cn.Execute "INSERT INTO petro VALUES('" & Null & "','" & Text5.Text &
"','" & Null & "','" & Text4.Text & "','" & Text6.Text & "','" & Null & "','" &
Null & "','" & Null & "','" & Null & "','" & Null & "','" & Null & "','" &
Form3.Text3.Text & "','" & Null & "','" & Null & "','" & Form3.Text2.Text &
"','" & Form3.Text4.Text & "','" & Form3.Text6.Text & "','" &
Form3.Text8.Text & "','" & Text17.Text & "','" & Text18.Text & "','" &
Text18.Text & "')"
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text4.SetFocus
End If
cn.CommitTrans
cn.Close: Set cn = Nothing
ab = 0
cd = 0
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
.Close: Set rs = Nothing
cn.Open GetConnection
a=1
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
If a < !inde Then
a = !inde
End If
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text18.Text = a + 1
Text15.Text = ab - cd
End Sub
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur2)
cd = cd + Val(!sal2)
.Close: Set rs = Nothing
If ab = 0 Then
MsgBox "Purchase petrolium first", vbExclamation, "Error 1025"
Form6.Show
Form2.Hide
Else
cn.Open GetConnection
cn.BeginTrans
cn.Execute "INSERT INTO petro VALUES('" & Null & "','" & Null & "','" &
Null & "','" & Null & "','" & Null & "','" & Null & "','" & Text11.Text & "','"
& Null & "','" & Text10.Text & "','" & Text12.Text & "','" & Null & "','" &
Null & "','" & Form3.Text5.Text & "','" & Null & "','" & Form3.Text2.Text &
"','" & Form3.Text4.Text & "','" & Form3.Text6.Text & "','" &
Form3.Text8.Text & "','" & Text17.Text & "','" & Text18.Text & "','" &
Text18.Text & "')"
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text10.SetFocus
End If
cn.CommitTrans
cn.Close: Set cn = Nothing
ab = 0
cd = 0
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur2)
cd = cd + Val(!sal2)
.Close: Set rs = Nothing
cn.Open GetConnection
a=1
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
If a < !inde Then
a = !inde
End If
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text18.Text = a + 1
Text14.Text = ab - cd
End Sub
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur2)
cd = cd + Val(!sal2)
.Close: Set rs = Nothing
If ab = 0 Then
MsgBox "Purchase petrolium first", vbExclamation, "Error 1025"
Form6.Show
Form2.Hide
Else
cn.Open GetConnection
cn.BeginTrans
cn.Execute "INSERT INTO petro VALUES('" & Null & "','" & Null & "','" &
Null & "','" & Null & "','" & Null & "','" & Null & "','" & Text8.Text & "','"
& Null & "','" & Text7.Text & "','" & Text9.Text & "','" & Null & "','" & Null
& "','" & Null & "','" & Form3.Text7.Text & "','" & Form3.Text2.Text & "','"
& Form3.Text4.Text & "','" & Form3.Text6.Text & "','" & Form3.Text8.Text
& "','" & Text17.Text & "','" & Text18.Text & "','" & Text18.Text & "')"
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text7.SetFocus
End If
cn.CommitTrans
cn.Close: Set cn = Nothing
ab = 0
cd = 0
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur2)
cd = cd + Val(!sal2)
.Close: Set rs = Nothing
cn.Open GetConnection
a=1
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
If a < !inde Then
a = !inde
End If
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text18.Text = a + 1
Text14.Text = ab - cd
End Sub
cn.Open GetConnection
a=1
With rs
.CursorLocation = adUseClient
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text18.Text = a + 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
ef = ef + Val(!pur2)
gh = gh + Val(!sal2)
.Close: Set rs = Nothing
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur2)
cd = cd + Val(!sal2)
.Close: Set rs = Nothing
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To n - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
ab = ab + Val(!pur1)
cd = cd + Val(!sal1)
.Close: Set rs = Nothing
End Sub
End Sub
CODE
cn.Open GetConnection
cn.BeginTrans
cn.Execute "UPDATE petro SET e1='" & Text1.Text & "',e2='" & Text3.Text
& "',e3='" & Text5.Text & "',e4='" & Text7.Text & "',a1='" & Text2.Text &
"',a2='" & Text4.Text & "',a3='" & Text6.Text & "',a4='" & Text8.Text & "'
WHERE inde=1"
Text1.SetFocus
cn.CommitTrans
cn.Close: Set cn = Nothing
End Sub
CODE
Private Sub Command1_Click()
cn.Open GetConnection
cn.BeginTrans
cn.Execute "INSERT INTO petro VALUES('" & Text2.Text & "','" & Null &
"','" & Text3.Text & "','" & Null & "','" & Null & "','" & Text5.Text & "','" &
Null & "','" & Text6.Text & "','" & Null & "','" & Null & "','" & Null & "','"
& Null & "','" & Null & "','" & Null & "','" & Null & "','" & Null & "','" &
Null & "','" & Null & "','" & Text1.Text & "','" & Text7.Text & "','" &
Text7.Text & "')"
Text2.Text = ""
Text3.Text = ""
Text5.Text = ""
Text6.Text = ""
Text2.SetFocus
cn.CommitTrans
cn.Close: Set cn = Nothing
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
Text7.Text = !inde + 1
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
End Sub
With rs
.CursorLocation = adUseClient
For i = 0 To .RecordCount - 1
If a < !inde Then
a = !inde
End If
.MoveNext
Next i
End If
.Close: Set rs = Nothing
End With
cn.Close: Set cn = Nothing
Text7.Text = a + 1
End Sub
CODE
Dim i As Long
Private Sub Command1_Click()
Form4.Show
Form7.Hide
End Sub
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
For i = 2 To a - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
a = .RecordCount
For i = 2 To a - 1
cn.Open GetConnection
With rs
.CursorLocation = adUseClient
.Open "SELECT * FROM petro WHERE ind = '" & i & " ' ", cn,
adOpenDynamic, adLockOptimistic
Print !amt11; Tab(35); !pur1; Tab(70); !dat; Tab(105); !amt21;
Tab(140); !pur2; Tab(175); !dat
.Close: Set rs = Nothing
End Sub
FORM 8( CREATE NEW USER NAME AND PASSWORD)
CODE
With rs
.CursorLocation = adUseClient
.Open "SELECT paswd FROM log ", cn, adOpenDynamic,
adLockOptimistic
For i = 0 To .RecordCount - 1
Form1.Hide
Form8.Hide
Form4.Show
Else
.MoveNext
MsgBox "Type Mismatch,", vbCritical, "Authentication Error"
Text3.Text = ""
Text4.Text = ""
Text3.SetFocus
End If
Else
MsgBox "Password Incorrect,", vbCritical, "Authentication
Error"
Text2.Text = ""
Text2.SetFocus
End If
Next i
End If
End Sub
After drawing all these forms and writing the code make a test run of
the software by the play button at the top side menu bar of the Visual Basic.
Now if all is correct we have to make it as a package so that it can be run on
any computer which doesn’t have a pre installed visual basic software. So
for binding the code and all supporting files and to make it installable on
WINDOWS from the file menu click ‘make file name.exe’