I have created the project with 2 forms. In the first form, I have 2 buttons. The first button has the backcolor as "fusia" by default. If I click the button means then backcolor of the button should change into red color. Thats why I have given the coding as
Expand|Select|Wrap|Line Numbers
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
- If Button1.BackColor = Drawing.Color.Fuchsia Then
- Button1.BackColor = Drawing.Color.Red
- End If
- End Sub
In my next form I have the textbox with one button asking for the credit card number . If the valid credit card number is entered in the textbox & the button is clicked, then the back color of the button1 in the previous form should get changed into blue color.
I have created the sql table named "seat1". In that I have the following fields as sno,b1,b2. The table has the data as
sno b1 b2
--------------------------
1 fu fu
---------------------------
fu-------> fusia as back color
b1------->button1
b2------->button2
Just like that in the b1 field (with sno as 1) in the DB should change into "bl" which means "Blue as BackColor". For that, I have created the session variable in the previous form & used that variable. The coding is as follows
PREVIOUS FORM:
Expand|Select|Wrap|Line Numbers
- Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
- Dim obj5 As Object
- obj5 = Button1.BackColor
- Session.Add("b1", obj5)
- End Sub
Expand|Select|Wrap|Line Numbers
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim obj5 As Object
- obj5 = CObj(Session("b1"))
- End Sub
sno b1 b2
--------------------------
1 bl fu
---------------------------
and at the same time button1 in the previous form should have the back color as blue by default. For this I have given the coding as
Expand|Select|Wrap|Line Numbers
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim obj5 As Object
- obj5 = CObj(Session("b1"))
- Dim con As SqlConnection
- Dim cmd As SqlCommand
- Dim str As String
- Dim rd As SqlDataReader
- str = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
- con = New SqlConnection(str)
- Try
- con.Open()
- Catch
- End Try
- cmd = New SqlCommand
- cmd.Connection = con
- cmd.CommandText = "select count(credit) from credit where credit='" & Trim(TextBox3.Text.ToString()) & "'"
- Dim cnt As Int16
- cnt = cmd.ExecuteScalar()
- If cnt <= 0 Then
- Response.Write("Un authorise user")
- Else
- Dim str1, str2 As String
- str1 = "user id=sa;password=;data source=AURO-RA4;initial catalog=suganya;server=AURO-RA4"
- con = New SqlConnection(str1)
- Try
- con.Open()
- Catch
- End Try
- str2 = "update seat1 set b1='bl' where sno='1'"
- cmd = New SqlCommand(str2, con)
- cmd.ExecuteNonQuery()
- con.Close()
- obj5 = Drawing.Color.Blue
- End If
- End Sub`