Wednesday, 16 October 2013

ATM REPORTING SYSTEM PROJECT-VB

INTRODUCTION

The project entitled "ATM Reporting system" has been developed using Serviette and Jsp as front end and Oracle8i as back end.
The main objective of this project is reporting application based on an existing client/database application. The existing application gathers all the transaction data from different ATM machine''. The goal of the application is to allow manager to view general reporting information through a web browser and not require the installation of the client or exhaustive training.

The scope of this application is 4 graphical reports, a security module. Which are ATM availability, Transaction types and volume, On-us and Not On-us transactions, Average withdrawal amounts etc., the reports will primarily be accessing data in the transaction log, which contains most of the prevalent information for managers. 

CODE
Account details
Imports System.Data.OleDb
Imports System.IO
Public Class AccountDetails

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Client.txtaccno.Text = Label8.Text
        Client.Show()
        Me.Close()
    End Sub

    Private Sub AccoutDetails_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As Integer = Trim(Client.txtaccno.Text)
        Try
            cmd = New OleDbCommand("select * from clients where accno='" & Trim(Client.txtaccno.Text) & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    Label6.Text = Trim(rs(0))
                    Label7.Text = Trim(rs(1))
                    Label8.Text = Trim(rs(2))
                    Label9.Text = Trim(rs(4))
                End While
            End If
            rs.Close()
            con.Close()
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
    End Sub
End Class
account settings
Imports System.Data.OleDb
Public Class accountsetting
    Dim x As Integer
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        LoginForm1.Show()
        Me.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            If txtopword.Text = "" Then
                MsgBox("Enter Old Password", MsgBoxStyle.Information, "New Password")
                txtopword.Focus()
            ElseIf txtnpword.Text = "" Then
                MsgBox("Enter New Password", MsgBoxStyle.Information, "New Password")
                txtnpword.Focus()
            ElseIf txtrpword.Text = "" Then
                MsgBox("Enter Retype Password", MsgBoxStyle.Information, "Retype Password")
                txtrpword.Focus()
            ElseIf txtnpword.Text <> txtrpword.Text Then
                MsgBox("Password & Retype Password mismatched", MsgBoxStyle.Information, "Password Mismatched")
                txtnpword.Text = ""
                txtrpword.Text = ""
                txtnpword.Focus()
            Else
                x = 0
                cmd = New OleDbCommand("select * from clients where accno='" & Trim(LCase(txtaccno.Text)) & "' and pwd='" & Trim(LCase(txtopword.Text)) & "'", con)
                con.Open()
                rs = cmd.ExecuteReader
                If rs.HasRows Then
                    While rs.Read
                        x = 1
                    End While
                Else
                    x = 2
                End If
                rs.Close()
                con.Close()
            End If
            If x = 1 Then
                cmd = New OleDbCommand("update auser set pword='" & Trim(LCase(txtnpword.Text)) & "' where pword='" & Trim(LCase(txtopword.Text)) & "'", con)
                con.Open()
                cmd.ExecuteNonQuery()
                MsgBox("Password Changed", MsgBoxStyle.Information, "Succeed")
                con.Close()
                cmd = New OleDbCommand("update clients set pwd='" & Trim(txtnpword.Text) & "' where pwd='" & Trim(txtopword.Text) & "'", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
                clr()


            ElseIf x = 2 Then
                MsgBox("Invalid Details", MsgBoxStyle.Critical, "Aborted")
                clr()
            End If
        Catch ex As Exception
            MsgBox(ex.Message(), MsgBoxStyle.Critical, "Error(s)")
        Finally
            con.Close()
        End Try
    End Sub
    Private Sub clr()
        txtaccno.Text = ""
        txtnpword.Text = ""
        txtopword.Text = ""
        txtrpword.Text = ""
        txtopword.Focus()
        x = 0
    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub
End Class
Admin
Imports System.Data.OleDb
Imports System.IO
Public Class Admin

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub LogoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogoutToolStripMenuItem.Click
        If MsgBox("Do you want to logout?", MsgBoxStyle.YesNo, "Ask") = MsgBoxResult.Yes Then
            LoginForm1.Show()
            Me.Close()
        End If
    End Sub

    Private Sub NewAccountToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewAccountToolStripMenuItem.Click
        newacc.Show()
        Me.Close()
    End Sub

    Private Sub ChangeAccountSettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeAccountSettingsToolStripMenuItem.Click
        accountsetting.Show()
        Me.Close()
    End Sub
    Dim a As String = ""
    Dim i As Integer = 0
    Dim j As Integer
    Dim accno(1000) As Integer
    Dim uname(1000), bname(1000), bal(1000), d(1000), dat(1000) As String

    Private Sub ATM1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM1ToolStripMenuItem.Click
        a = "ATM1"
        Try
            cmd = New OleDbCommand("select * from transactions where atms='" & Trim(a.ToString()) & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    i = i + 1
                    uname(i) = Trim(rs(0))
                    accno(i) = Trim(rs(1))
                    bname(i) = Trim(rs(2))
                    bal(i) = Trim(rs(3))
                    d(i) = Trim(rs(4))
                    dat(i) = Trim(rs(6))
                End While
            End If
            rs.Close()
            con.Close()
            cmd = New OleDbCommand("delete from ATM1", con)
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close()

            For j = 1 To i
                cmd = New OleDbCommand("insert into ATM1 values('" & Trim(uname(j).ToString()) & "', '" & Trim(accno(j).ToString()) & "','" & Trim(bname(j).ToString()) & "','" & Trim(bal(j).ToString()) & "','" & Trim(d(j).ToString()) & "','" & Trim(dat(j).ToString()) & "')", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            Next
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
        Form1.Show()
        Me.Close()
    End Sub

    Private Sub ATM2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM2ToolStripMenuItem.Click
        a = "ATM2"
        Try
            cmd = New OleDbCommand("select * from transactions where atms='" & Trim(a.ToString()) & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    i = i + 1
                    uname(i) = Trim(rs(0))
                    accno(i) = Trim(rs(1))
                    bname(i) = Trim(rs(2))
                    bal(i) = Trim(rs(3))
                    d(i) = Trim(rs(4))
                    dat(i) = Trim(rs(6))
                End While
            End If
            rs.Close()
            con.Close()
            cmd = New OleDbCommand("delete from ATM2", con)
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close()

            For j = 1 To i
                cmd = New OleDbCommand("insert into ATM2 values('" & Trim(uname(j).ToString()) & "', '" & Trim(accno(j).ToString()) & "','" & Trim(bname(j).ToString()) & "','" & Trim(bal(j).ToString()) & "','" & Trim(d(j).ToString()) & "','" & Trim(dat(j).ToString()) & "')", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            Next
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
        Form2.Show()
        Me.Close()

    End Sub

    Private Sub ATM3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM3ToolStripMenuItem.Click
        a = "ATM3"
        Try
            cmd = New OleDbCommand("select * from transactions where atms='" & Trim(a.ToString()) & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    i = i + 1
                    uname(i) = Trim(rs(0))
                    accno(i) = Trim(rs(1))
                    bname(i) = Trim(rs(2))
                    bal(i) = Trim(rs(3))
                    d(i) = Trim(rs(4))
                    dat(i) = Trim(rs(6))
                End While
            End If
            rs.Close()
            con.Close()
            cmd = New OleDbCommand("delete from ATM3", con)
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close()

            For j = 1 To i
                cmd = New OleDbCommand("insert into ATM3 values('" & Trim(uname(j).ToString()) & "', '" & Trim(accno(j).ToString()) & "','" & Trim(bname(j).ToString()) & "','" & Trim(bal(j).ToString()) & "','" & Trim(d(j).ToString()) & "','" & Trim(dat(j).ToString()) & "')", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            Next
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
        Form3.Show()
        Me.Close()
    End Sub

    Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click
        If MsgBox("Do you want to exit?", MsgBoxStyle.YesNo, "Ask?") = MsgBoxResult.Yes Then
            End
        End If
    End Sub
End Class
Client
Public Class Client
    Dim a As String = ""

    Private Sub CheckAccountDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckAccountDetailsToolStripMenuItem.Click
        AccountDetails.show()
        Me.Close()
    End Sub

    Private Sub ATM1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM1ToolStripMenuItem.Click
        txtatm.Text = "ATM1"
        WithDrawls.Show()
        Me.Close()
    End Sub

    Private Sub ATM2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM2ToolStripMenuItem.Click
        txtatm.Text = "ATM2"
        WithDrawls.Show()
        Me.Close()
    End Sub

    Private Sub ATM3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATM3ToolStripMenuItem.Click
        txtatm.Text = "ATM3"
        WithDrawls.Show()
        Me.Close()
    End Sub

    Private Sub LogoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogoutToolStripMenuItem.Click
        If MsgBox("Do you want to logout?", MsgBoxStyle.YesNo, "Ask") = MsgBoxResult.Yes Then
            LoginForm1.Show()
            Me.Close()
        End If
    End Sub

    Private Sub EndToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EndToolStripMenuItem.Click
        If MsgBox("Do you want to exit?", MsgBoxStyle.YesNo, "Ask?") = MsgBoxResult.Yes Then
            End
        End If

    End Sub

    Private Sub WithdrawlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WithdrawlToolStripMenuItem.Click

    End Sub

    Private Sub Client_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
Login form
Imports System.Data.OleDb
Imports System.IO
Public Class LoginForm1
    Dim s, i, j As Integer
    Dim acno As String = ""

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        i = 0
        j = 0
        If Trim(LCase(txtuname.Text)) = "admin" And Trim(LCase(txtpword.Text)) = "admin" Then
            Admin.Show()
        Else
            Try
                cmd = New OleDbCommand("select * from auser where uname='" & Trim(LCase(txtuname.Text)) & "' and pword='" & Trim(LCase(txtpword.Text)) & "'", con)
                con.Open()
                rs = cmd.ExecuteReader()
                If rs.HasRows Then
                    While rs.Read
                        i = 1
                    End While
                Else
                    i = 2
                End If
                rs.Close()
                con.Close()
            Catch ex As Exception
                MsgBox(ex.Message(), MsgBoxStyle.Critical, "Process Aborted")
            Finally
                con.Close()
            End Try
            If i = 1 Then
                cmd = New OleDbCommand("select * from clients where uname= '" & Trim(LCase(txtuname.Text)) & "' and pwd='" & Trim(txtpword.Text) & "'", con)
                con.Open()
                rs = cmd.ExecuteReader
                If rs.HasRows Then
                    While rs.Read
                        acno = Trim(rs(2))
                    End While
                End If
                rs.Close()
                con.Close()
                Client.txtaccno.Text = Trim(acno)
                Client.Show()
                clr()
                Me.Hide()
            ElseIf i = 2 Then
                MsgBox("Invalid Details", MsgBoxStyle.Critical, "Access Denied")
                clr()
            End If

        End If

    End Sub
    Private Sub clr()
        txtuname.Text = ""
        txtpword.Text = ""
        txtuname.Focus()
    End Sub
    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub UsernameLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsernameLabel.Click

    End Sub
End Class
New account
Imports System.Data.OleDb
Imports System.IO
Public Class newacc
    Dim j, k, x, y As Decimal

    Private Sub newacc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        accno()
        pwd()
    End Sub
    Private Sub accno()
        x = 0
first:
        Dim r As New Random
        j = r.Next(111111111, 999999999)
        Try
            cmd = New OleDbCommand("select * from clients where accno='" & j & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    x = 1
                End While
            Else
                x = 2
            End If
            rs.Close()
            con.Close()
        Catch ex As Exception
            con.Close()
            MsgBox(ex.Message(), MsgBoxStyle.Critical, "Process Aborted")
        End Try
        If x = 1 Then
            GoTo first
        ElseIf x = 2 Or x = 0 Then
            txtaccno.Text = j.ToString()
        End If
    End Sub
    Private Sub pwd()
        y = 0
first:
        Dim q As New Random
        k = q.Next(1111, 9999)
        Try
            cmd = New OleDbCommand("select * from clients where pwd='" & k & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    y = 1
                End While
            Else
                y = 2
            End If
            rs.Close()
            con.Close()
        Catch ex As Exception
            con.Close()
            MsgBox(ex.Message(), MsgBoxStyle.Critical, "Process Aborted")
        End Try
        If y = 1 Then
            GoTo first
        ElseIf y = 2 Or y = 0 Then
            txtpwd.Text = k.ToString()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            cmd = New OleDbCommand("insert into clients values('" & Trim(txtname.Text) & "','" & Trim(txtbname.Text) & "','" & Trim(txtaccno.Text) & "','" & Trim(txtpwd.Text) & "','" & Trim(txtbalance.Text) & "')", con)
            con.Open()
            cmd.ExecuteNonQuery()
            MsgBox("Saved Successfully")
            con.Close()
            cmd = New OleDbCommand("insert into auser values('" & Trim(txtname.Text) & "','" & Trim(txtpwd.Text) & "')", con)
            con.Open()
            cmd.ExecuteNonQuery()
            con.Close()
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'txtname.Text = ""
        'txtbname.Text = ""
        'txtaccno.Text = ""
        'txtbalance.Text = ""
        'txtpwd.Text = ""
        Me.Refresh()
        accno()
        pwd()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Admin.Show()
        Me.Close()
    End Sub
End Class
Withdrawals
Imports System.Data.OleDb
Public Class WithDrawls
    Dim b, bal, ac As Integer
    Dim atm, nam, accno, bname, d, dat As String
    Private Sub WithDrawls_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtaccno.Text = Trim(Client.txtaccno.Text)
        ac = Trim(txtaccno.Text)
        atm = Trim(Client.txtatm.Text)
        b = 0
        chkbal()
    End Sub
    Dim i As Integer = 0
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        i = 100
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        i = 500
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        i = 1000
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        i = 10000
    End Sub
    Private Sub chkbal()
        d = "WithDrawls"
        dat = Date.Now
        Try
            cmd = New OleDbCommand("select * from clients where accno='" & Trim(txtaccno.Text) & "'", con)
            con.Open()
            rs = cmd.ExecuteReader
            If rs.HasRows Then
                While rs.Read
                    nam = Trim(rs(0))
                    bname = Trim(rs(1))
                    b = Trim(rs(4))
                End While
            End If
            rs.Close()
            con.Close()
            Label3.Text = "Rs." & Val(b) & "/-"
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            bal = 0
            If Val(b) < Val(i) Then
                Label4.Text = "You can't make withdrawl because of insufficient balance! Rs." & Val(b) & "/-"
            Else
                bal = Val(b) - Val(i)
                cmd = New OleDbCommand("update clients set balance='" & Val(bal) & "' where accno='" & Trim(txtaccno.Text) & "'", con)
                con.Open()
                cmd.ExecuteNonQuery()
                MsgBox("Transaction Succeed!")
                Label3.Text = "Rs." & Val(bal) & "/-"
                con.Close()
                cmd = New OleDbCommand("insert into transactions values('" & Trim(nam.ToString()) & "','" & Trim(txtaccno.Text) & "','" & Trim(bname.ToString()) & "','" & Val(bal) & "','" & Trim(d.ToString()) & "','" & Trim(atm.ToString()) & "','" & Trim(dat.ToString()) & "')", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
                chkbal()
            End If
        Catch ex As Exception
            MsgBox(ex.Message())
        Finally
            con.Close()
        End Try
        TextBox1.Text = ""
    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Client.txtaccno.Text = Trim(ac)
        Client.Show()
        Me.Close()
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        i = Val(TextBox1.Text)
    End Sub
End Class

No comments:

Post a Comment