0

Hi,
In vb.net2008 if we want to disable/enable the groupbox
as per condition.Then how its possible when we used save button.how its insert into database.following is the code:


Imports System.Data.OleDb
Public Class addcust
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim cmd As OleDbCommand
Dim cmd1 As OleDbCommand
Dim cid As Integer
Dim rc As Integer
Dim s As String
Dim r As String
Dim ch As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Module1.connect()
If TextBox1.Text = "" Then
MsgBox("Please, Enter a Customer's First Name")
Exit Sub
End If
If TextBox2.Text = "" Then
MsgBox("Please, Enter a Customer's Last Name")
Exit Sub
End If
If TextBox3.Text = "" Then
MsgBox("Please, Enter a Office Address")
Exit Sub
End If
If TextBox4.Text = "" Then
MsgBox("Please, Enter a Home Address")
Exit Sub
End If
'If DateTimePicker. = "" Then
'MsgBox("Please, Enter a Date Of Birth")
'Exit Sub
'End If
If ComboBox2.Text = "" Then
MsgBox("Please, Enter a Gender")
Exit Sub
End If
If TextBox5.Text = "" Then
MsgBox("Please, Enter a Email ID")
Exit Sub
End If
If TextBox6.Text = "" Then
MsgBox("Please, Enter a Office Phone")
Exit Sub
End If
If TextBox7.Text = "" Then
MsgBox("Please, Enter a Home Phone")
Exit Sub
End If
If TextBox8.Text = "" Then
MsgBox("Please, Enter a Account Number")
Exit Sub
End If
If ComboBox3.Text = "" Then
MsgBox("Please, Enter a Account type")
Exit Sub
End If
'If TextBox9.Text = "" Then
'MsgBox("Please, Enter a ATM Number")
'Exit Sub
'End If
If TextBox10.Text = "" Then
MsgBox("Please, Enter a Balance")
Exit Sub
End If
If ComboBox3.Text = "" Then
MsgBox("Please, Enter a Date")
Exit Sub
End If
If TextBox13.Text = "" Then
MsgBox("Please, Enter a Name1")
Exit Sub
End If
If TextBox14.Text = "" Then
MsgBox("Please, Enter a Name2")
Exit Sub
End If
If TextBox15.Text = "" Then
MsgBox("Please, Enter a Name3")
Exit Sub
End If
'If MsgBox("Are You Sure ? ", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.Yes Then
If ComboBox1.Text = "Personal" Then
s = "insert into addcust(first_name,last_name,office_add,home_add,d_o_b,gender,email_id,office_ph,home_ph,account_no,acc_type,balance,date,acc_desc) values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & dtp1.Value & "','" & ComboBox2.Text & "','" & TextBox5.Text & "'," & CInt(TextBox6.Text) & "," & CInt(TextBox7.Text) & ",'" & TextBox8.Text & "','" & ComboBox3.Text & "'," & CInt(TextBox9.Text) & ",'" & dtp2.Value & "'," & CInt(TextBox10.Text) & ",'" & ComboBox1.Text & "'"
Else
s = "insert into addcust values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & dtp1.Value & "','" & ComboBox2.Text & "','" & TextBox5.Text & "'," & CInt(TextBox6.Text) & "," & CInt(TextBox7.Text) & ",'" & TextBox8.Text & "','" & ComboBox3.Text & "'," & CInt(TextBox9.Text) & ",'" & dtp2.Value & "'," & CInt(TextBox10.Text) & ",'" & ComboBox1.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & TextBox15.Text & "'"
's = InsertRecords("banking", "first_name", Trim(TextBox1.Text), "last_name", Trim(TextBox2.Text), "office_add", Trim(TextBox3.Text), "home_add", Trim(TextBox4.Text), "d_o_b", (dtp1.Value), "gender", Trim(ComboBox2.Text), "email_id", Trim(TextBox5.Text), "office_ph", CInt(TextBox6.Text), "home_ph", CInt(TextBox7.Text), "account_no", Trim(TextBox8.Text), "acc_type", ComboBox3.Text, "balace", Trim(TextBox9.Text), "date", dtp2.Value, "acc_desc", ComboBox1.Text, "name1", Trim(TextBox13.Text), "name2", Trim(TextBox14.Text), "name3", Trim(TextBox15.Text), "pix", Trim(TextBox11.Text))

cmd = New OleDbCommand(s, conn)
conn.Open()
cmd.ExecuteNonQuery()
MsgBox("Record has been entered")
Button1.Enabled = False
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
custview.Show()
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
OpenFileDialog1.Title = "Get Image"
OpenFileDialog1.ShowDialog()
If (TextBox11.Text.Trim() <> "") Then
PictureBox1.Image = Image.FromFile(TextBox11.Text)
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
PictureBox1.Image = Nothing
End Sub
Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox11.TextChanged
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox11.Text = OpenFileDialog1.FileName
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "Personal" Then
GroupBox3.Enabled = False
Else
GroupBox3.Enabled = True
End If

End Sub
End Class

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Piya27
0

Hi sandli28,

Use bb code tags to post your source code.

...
(ur code statements)
...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.