
Imports System.Data.Odbc
Partial Class Transactions
Inherits System.Web.UI.Page
Dim x As Date = Date.Today.ToShortDateString
Dim con As New OdbcConnection("Dsn=MYODBC")
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text.ToUpper()
Dim str As String
str = "Select * from trans where acno='" & TextBox1.Text & "' order by tid desc"
Dim com As New OdbcCommand(str, con)
Dim r As OdbcDataReader
Try
con.Open()
r = com.ExecuteReader
r.Read()
TextBox2.Text = r("BalAftTrans")
Label1.Text = Val(r("tid")) + 1
r.Close()
Label3.Text = x
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
TextBox2.Visible = True
DropDownList1.Visible = True
TextBox4.Visible = True
Button3.Visible = True
'MsgBox("Account Found")
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If DropDownList1.Text = "Debit" Then
If Val(TextBox2.Text) <= 300 Then
MsgBox("Account with minimum balance only. Withdraw not allowed", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalied Transaction")
ElseIf Val(TextBox4.Text) > (Val(TextBox2.Text) - 300) Then
MsgBox("Insufficient funds in your account. Withdraw not allowed", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalied Transaction")
Else
Label2.Text = Val(TextBox2.Text) - Val(TextBox4.Text)
inputs()
End If
Else
Label2.Text = Val(TextBox2.Text) + Val(TextBox4.Text)
inputs()
End If
End Sub
Private Sub inputs()
Dim tra As String
tra = "Insert into trans values(" & Label1.Text & ",'" & TextBox1.Text & "','" & Label3.Text & "','" & DropDownList1.Text & "','" & Label4.Text & "'," & TextBox4.Text & "," & TextBox2.Text & "," & Label2.Text & ")"
Dim com1 As New OdbcCommand(tra, con)
Try
con.Open()
Dim a As Integer
a = com1.ExecuteNonQuery
MsgBox(DropDownList1.Text & " sucessfully Completed. your Account balance is Rs." & Label2.Text, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Transaction info")
Response.Redirect("New_Account.aspx")
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
End Class