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 ClassAFAIK the only way to do it is to place the save button outside the group box control. Without knowing how your applications UI looks like (and how you want it to look like), I would put the Save, Ok, Cancel and similar buttons outside of the group box and enable/disable them separately.
HTH
sandli28,
Duplicate Thread :
http://www.daniweb.com/forums/thread204221.html
Then how its possible when we used save button.how its insert into database.
I didn't get you. Where is a problem?
you have written the code to insert the values into the database.. then u are asking how to insert into database...
well If I am guessing right, you want to save into database after hiding the groupbox?? or may be there's some other problem??
you have written the code to insert the values into the database.. then u are asking how to insert into database... well If I am guessing right, you want to save into database after hiding the groupbox?? or may be there's some other problem??
yes,this is my problem actually after disabling the groupbox when i insert the record into database by clicking on save button its gives the error on textbox which specify in disable groupbox.Actually,I want that when user select the personal account then groupbox of joint account disable and textbox in that groupbox also not working and when user select the joint account then this groupbox enable with textbox specify int it.but when i select the personnal a/c ,its no doubt disable the groupbox but not disable the textbox specify in groupbox.so,how i insert my record.
Thanx,
Regards,
Sandeep
yes,this is my problem actually after disabling the groupbox when i insert the record into database by clicking on save button its gives the error on textbox which specify in disable groupbox.Actually,I want that when user select the personal account then groupbox of joint account disable and textbox in that groupbox also not working and when user select the joint account then this groupbox enable with textbox specify int it.but when i select the personnal a/c ,its no doubt disable the groupbox but not disable the textbox specify in groupbox.so,how i insert my record.
Thanx, Regards, Sandeep
I am not sure, but if you want to use the text box from the groupbox then why to disable the groupbox at all? Or save the data from that textbox into some variable and then disable the groupbox.
I am not sure, but if you want to use the text box from the groupbox then why to disable the groupbox at all? Or save the data from that textbox into some variable and then disable the groupbox.
actually its as per condition.I have a project on banking system.so there is two type of account personal and joint a/c.so,as per condition if user select the joint a/c then he must be specified the name of other members who is involved in joint a/c for that i specify the textbox in groupbox.and if user select the personal a/c then these textbox must be disable.but in this coding when user select the personal a/c,its giving the error,"plz enter the name" which is a first textbox of joint a/c specify in groupbox.
Regards,
Sandeep
actually its as per condition.I have a project on banking system.so there is two type of account personal and joint a/c.so,as per condition if user select the joint a/c then he must be specified the name of other members who is involved in joint a/c for that i specify the textbox in groupbox.and if user select the personal a/c then these textbox must be disable.but in this coding when user select the personal a/c,its giving the error,"plz enter the name" which is a first textbox of joint a/c specify in groupbox.
Regards, Sandeep
can you please attach the snapshot of your form here.. so we can get an idea of what actually your problem is...
as far as i can guess..u want to disable the groupbox but also want to extract data from there also..or is it like after disabling the goupbox you want to enter the data(which incase is notpossible).. or you may put that textbox outside the groupbox...